From 89617da623512b5562a86dcb3bd2e71806c61af2 Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Tue, 28 Jun 2022 00:43:27 +0000 Subject: [PATCH 1/2] chore(codegen): parseErrorCode returns optional string --- .../amazon/smithy/aws/typescript/codegen/AwsEc2.java | 7 ++----- .../amazon/smithy/aws/typescript/codegen/AwsQuery.java | 7 ++----- .../amazon/smithy/aws/typescript/codegen/AwsRestXml.java | 7 ++----- .../aws/typescript/codegen/JsonRpcProtocolGenerator.java | 2 +- .../aws/typescript/codegen/RestJsonProtocolGenerator.java | 2 +- .../aws/typescript/codegen/load-json-error-code-stub.ts | 4 +--- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java index 062c13fc7c7af..420c4bcfbbc09 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsEc2.java @@ -96,7 +96,7 @@ public void generateSharedComponents(GenerationContext context) { writer.openBlock("const loadEc2ErrorCode = (\n" + " output: $T,\n" + " data: any\n" - + "): string => {", "};", responseType, () -> { + + "): string | undefined => {", "};", responseType, () -> { // Attempt to fetch the error code from the specific location. String errorCodeLocation = getErrorBodyLocation(context, "data") + ".Code"; writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> { @@ -105,9 +105,6 @@ public void generateSharedComponents(GenerationContext context) { // Default a 404 status code to the NotFound code. writer.openBlock("if (output.statusCode == 404) {", "}", () -> writer.write("return 'NotFound';")); - - // Default to an empty error code so an unmodeled exception is built. - writer.write("return '';"); }); writer.write(""); } @@ -153,7 +150,7 @@ protected void writeErrorCodeParser(GenerationContext context) { TypeScriptWriter writer = context.getWriter(); // Outsource error code parsing since it's complex for this protocol. - writer.write("errorCode = loadEc2ErrorCode(output, parsedOutput.body);"); + writer.write("const errorCode = loadEc2ErrorCode(output, parsedOutput.body);"); } @Override diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java index 055375d5b7597..25a5fc9636606 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsQuery.java @@ -96,7 +96,7 @@ public void generateSharedComponents(GenerationContext context) { writer.openBlock("const loadQueryErrorCode = (\n" + " output: $T,\n" + " data: any\n" - + "): string => {", "};", responseType, () -> { + + "): string | undefined => {", "};", responseType, () -> { // Attempt to fetch the error code from the specific location. String errorCodeLocation = getErrorBodyLocation(context, "data") + ".Code"; writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> { @@ -105,9 +105,6 @@ public void generateSharedComponents(GenerationContext context) { // Default a 404 status code to the NotFound code. writer.openBlock("if (output.statusCode == 404) {", "}", () -> writer.write("return 'NotFound';")); - - // Default to an empty error code so an unmodeled exception is built. - writer.write("return '';"); }); writer.write(""); } @@ -153,7 +150,7 @@ protected void writeErrorCodeParser(GenerationContext context) { TypeScriptWriter writer = context.getWriter(); // Outsource error code parsing since it's complex for this protocol. - writer.write("errorCode = loadQueryErrorCode(output, parsedOutput.body);"); + writer.write("const errorCode = loadQueryErrorCode(output, parsedOutput.body);"); } @Override diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java index 4fbe1e5bae41d..a2b6dfc595a36 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsRestXml.java @@ -112,7 +112,7 @@ public void generateSharedComponents(GenerationContext context) { writer.openBlock("const loadRestXmlErrorCode = (\n" + " output: $T,\n" + " data: any\n" - + "): string => {", "};", responseType, () -> { + + "): string | undefined => {", "};", responseType, () -> { // Attempt to fetch the error code from the specific location. String errorCodeLocation = getErrorBodyLocation(context, "data") + ".Code"; writer.openBlock("if ($L !== undefined) {", "}", errorCodeLocation, () -> { @@ -121,9 +121,6 @@ public void generateSharedComponents(GenerationContext context) { // Default a 404 status code to the NotFound code. writer.openBlock("if (output.statusCode == 404) {", "}", () -> writer.write("return 'NotFound';")); - - // Default to an empty error code so an unmodeled exception is built. - writer.write("return '';"); }); writer.write(""); } @@ -319,7 +316,7 @@ protected void writeErrorCodeParser(GenerationContext context) { TypeScriptWriter writer = context.getWriter(); // Outsource error code parsing since it's complex for this protocol. - writer.write("errorCode = loadRestXmlErrorCode(output, parsedOutput.body);"); + writer.write("const errorCode = loadRestXmlErrorCode(output, parsedOutput.body);"); } @Override diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java index ec46a7bbfffc9..714c7a03de066 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/JsonRpcProtocolGenerator.java @@ -128,7 +128,7 @@ protected void writeErrorCodeParser(GenerationContext context) { TypeScriptWriter writer = context.getWriter(); // Outsource error code parsing since it's complex for this protocol. - writer.write("errorCode = loadRestJsonErrorCode(output, parsedOutput.body);"); + writer.write("const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);"); } @Override diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/RestJsonProtocolGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/RestJsonProtocolGenerator.java index e6e8a9c0796ad..338c79ae2bde1 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/RestJsonProtocolGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/RestJsonProtocolGenerator.java @@ -245,7 +245,7 @@ protected void writeErrorCodeParser(GenerationContext context) { TypeScriptWriter writer = context.getWriter(); // Outsource error code parsing since it's complex for this protocol. - writer.write("errorCode = loadRestJsonErrorCode(output, parsedOutput.body);"); + writer.write("const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);"); } @Override diff --git a/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/load-json-error-code-stub.ts b/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/load-json-error-code-stub.ts index 5f40a5b15b80d..e8dbdf12ee1b1 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/load-json-error-code-stub.ts +++ b/codegen/smithy-aws-typescript-codegen/src/main/resources/software/amazon/smithy/aws/typescript/codegen/load-json-error-code-stub.ts @@ -1,7 +1,7 @@ /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -27,6 +27,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; From ddd6893ae4d8d29534ee463b631b996b3da34848 Mon Sep 17 00:00:00 2001 From: AllanZhengYP Date: Tue, 28 Jun 2022 00:48:56 +0000 Subject: [PATCH 2/2] feat(clients): fallback to status code for unmodeled errors --- .../src/protocols/Aws_restJson1.ts | 256 +- .../src/protocols/Aws_restJson1.ts | 31 +- .../src/protocols/Aws_json1_1.ts | 211 +- .../client-acm/src/protocols/Aws_json1_1.ts | 139 +- .../src/protocols/Aws_json1_1.ts | 841 +-- .../client-amp/src/protocols/Aws_restJson1.ts | 157 +- .../src/protocols/Aws_restJson1.ts | 337 +- .../src/protocols/Aws_restJson1.ts | 283 +- .../src/protocols/Aws_restJson1.ts | 130 +- .../src/protocols/Aws_restJson1.ts | 1084 ++-- .../src/protocols/Aws_restJson1.ts | 31 +- .../src/protocols/Aws_restJson1.ts | 652 ++- .../src/protocols/Aws_restJson1.ts | 346 +- .../src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_restJson1.ts | 202 +- .../src/protocols/Aws_restJson1.ts | 139 +- .../src/protocols/Aws_json1_1.ts | 94 +- .../src/protocols/Aws_json1_1.ts | 229 +- .../src/protocols/Aws_json1_1.ts | 247 +- .../src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_json1_0.ts | 274 +- .../src/protocols/Aws_json1_1.ts | 589 ++- .../src/protocols/Aws_restJson1.ts | 445 +- .../src/protocols/Aws_json1_1.ts | 319 +- .../src/protocols/Aws_restJson1.ts | 553 +- .../src/protocols/Aws_json1_1.ts | 58 +- .../src/protocols/Aws_query.ts | 552 +- .../src/protocols/Aws_json1_0.ts | 166 +- .../src/protocols/Aws_restJson1.ts | 598 ++- .../src/protocols/Aws_restJson1.ts | 220 +- .../src/protocols/Aws_restJson1.ts | 274 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_json1_1.ts | 211 +- .../src/protocols/Aws_restJson1.ts | 220 +- .../src/protocols/Aws_restJson1.ts | 67 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_restJson1.ts | 418 +- .../src/protocols/Aws_restJson1.ts | 1714 +++--- .../src/protocols/Aws_json1_1.ts | 121 +- .../src/protocols/Aws_json1_0.ts | 76 +- .../src/protocols/Aws_restJson1.ts | 598 ++- .../src/protocols/Aws_query.ts | 597 ++- .../src/protocols/Aws_restXml.ts | 831 +-- .../src/protocols/Aws_json1_1.ts | 139 +- .../src/protocols/Aws_json1_1.ts | 184 +- .../src/protocols/Aws_restJson1.ts | 31 +- .../src/protocols/Aws_query.ts | 237 +- .../src/protocols/Aws_json1_1.ts | 265 +- .../src/protocols/Aws_json1_1.ts | 463 +- .../src/protocols/Aws_json1_1.ts | 382 +- .../src/protocols/Aws_query.ts | 327 +- .../src/protocols/Aws_restJson1.ts | 310 +- .../src/protocols/Aws_json1_1.ts | 409 +- .../src/protocols/Aws_json1_1.ts | 697 +-- .../src/protocols/Aws_json1_1.ts | 427 +- .../src/protocols/Aws_restJson1.ts | 130 +- .../src/protocols/Aws_restJson1.ts | 211 +- .../src/protocols/Aws_json1_1.ts | 355 +- .../src/protocols/Aws_json1_0.ts | 112 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_json1_1.ts | 166 +- .../src/protocols/Aws_json1_1.ts | 913 ++-- .../src/protocols/Aws_json1_1.ts | 211 +- .../src/protocols/Aws_restJson1.ts | 157 +- .../src/protocols/Aws_json1_1.ts | 643 ++- .../src/protocols/Aws_json1_1.ts | 238 +- .../src/protocols/Aws_json1_0.ts | 166 +- .../src/protocols/Aws_json1_1.ts | 796 +-- .../src/protocols/Aws_restJson1.ts | 13 +- .../src/protocols/Aws_restJson1.ts | 1363 ++--- .../src/protocols/Aws_restJson1.ts | 202 +- .../src/protocols/Aws_restJson1.ts | 76 +- .../src/protocols/Aws_json1_1.ts | 40 +- .../src/protocols/Aws_json1_1.ts | 319 +- .../src/protocols/Aws_restJson1.ts | 346 +- .../src/protocols/Aws_json1_1.ts | 175 +- .../src/protocols/Aws_json1_1.ts | 580 +- .../src/protocols/Aws_restJson1.ts | 400 +- .../src/protocols/Aws_restJson1.ts | 265 +- .../src/protocols/Aws_json1_1.ts | 382 +- .../client-dax/src/protocols/Aws_json1_1.ts | 193 +- .../src/protocols/Aws_restJson1.ts | 184 +- .../src/protocols/Aws_json1_1.ts | 697 +-- .../src/protocols/Aws_restJson1.ts | 265 +- .../src/protocols/Aws_json1_1.ts | 571 +- .../src/protocols/Aws_json1_1.ts | 589 ++- .../client-dlm/src/protocols/Aws_restJson1.ts | 76 +- .../client-docdb/src/protocols/Aws_query.ts | 480 +- .../client-drs/src/protocols/Aws_restJson1.ts | 292 +- .../src/protocols/Aws_json1_0.ts | 40 +- .../src/protocols/Aws_json1_0.ts | 454 +- .../client-ebs/src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_json1_1.ts | 22 +- clients/client-ec2/src/protocols/Aws_ec2.ts | 4710 +++++++++-------- .../src/protocols/Aws_json1_1.ts | 211 +- .../client-ecr/src/protocols/Aws_json1_1.ts | 373 +- .../client-ecs/src/protocols/Aws_json1_1.ts | 472 +- .../client-efs/src/protocols/Aws_restJson1.ts | 274 +- .../client-eks/src/protocols/Aws_restJson1.ts | 310 +- .../src/protocols/Aws_query.ts | 426 +- .../src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_query.ts | 309 +- .../src/protocols/Aws_query.ts | 264 +- .../src/protocols/Aws_restJson1.ts | 157 +- .../src/protocols/Aws_query.ts | 588 +- .../src/protocols/Aws_restJson1.ts | 373 +- .../src/protocols/Aws_restJson1.ts | 139 +- .../src/protocols/Aws_restJson1.ts | 130 +- .../client-emr/src/protocols/Aws_json1_1.ts | 472 +- .../src/protocols/Aws_json1_1.ts | 508 +- .../src/protocols/Aws_restJson1.ts | 292 +- .../src/protocols/Aws_restJson1.ts | 274 +- .../src/protocols/Aws_restJson1.ts | 76 +- .../src/protocols/Aws_json1_1.ts | 112 +- .../client-fis/src/protocols/Aws_restJson1.ts | 148 +- .../client-fms/src/protocols/Aws_json1_1.ts | 274 +- .../src/protocols/Aws_json1_1.ts | 463 +- .../src/protocols/Aws_json1_1.ts | 13 +- .../src/protocols/Aws_json1_1.ts | 616 ++- .../client-fsx/src/protocols/Aws_json1_1.ts | 337 +- .../src/protocols/Aws_json1_1.ts | 859 +-- .../src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_json1_1.ts | 427 +- .../client-glue/src/protocols/Aws_json1_1.ts | 1660 +++--- .../src/protocols/Aws_restJson1.ts | 148 +- .../src/protocols/Aws_restJson1.ts | 832 +-- .../src/protocols/Aws_restJson1.ts | 265 +- .../src/protocols/Aws_restJson1.ts | 229 +- .../src/protocols/Aws_restJson1.ts | 562 +- .../src/protocols/Aws_json1_1.ts | 121 +- .../src/protocols/Aws_json1_0.ts | 121 +- .../src/protocols/Aws_restJson1.ts | 139 +- clients/client-iam/src/protocols/Aws_query.ts | 1425 ++--- .../src/protocols/Aws_json1_1.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 454 +- .../src/protocols/Aws_json1_1.ts | 337 +- .../src/protocols/Aws_restJson1.ts | 274 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_restJson1.ts | 148 +- .../src/protocols/Aws_restJson1.ts | 67 +- .../src/protocols/Aws_restJson1.ts | 112 +- .../src/protocols/Aws_restJson1.ts | 238 +- .../src/protocols/Aws_restJson1.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 841 +-- .../client-iot/src/protocols/Aws_restJson1.ts | 2137 ++++---- .../src/protocols/Aws_restJson1.ts | 310 +- .../src/protocols/Aws_restJson1.ts | 130 +- .../src/protocols/Aws_restJson1.ts | 76 +- .../src/protocols/Aws_json1_1.ts | 76 +- .../src/protocols/Aws_restJson1.ts | 616 ++- .../src/protocols/Aws_json1_1.ts | 319 +- .../src/protocols/Aws_restJson1.ts | 238 +- .../client-ivs/src/protocols/Aws_restJson1.ts | 256 +- .../src/protocols/Aws_restJson1.ts | 112 +- .../src/protocols/Aws_restJson1.ts | 319 +- .../src/protocols/Aws_restJson1.ts | 112 +- .../src/protocols/Aws_json1_1.ts | 499 +- .../src/protocols/Aws_json1_0.ts | 121 +- .../src/protocols/Aws_json1_1.ts | 283 +- .../src/protocols/Aws_json1_1.ts | 184 +- .../src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_restJson1.ts | 13 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_restJson1.ts | 211 +- .../src/protocols/Aws_json1_1.ts | 265 +- .../client-kms/src/protocols/Aws_json1_1.ts | 454 +- .../src/protocols/Aws_restJson1.ts | 400 +- .../src/protocols/Aws_restJson1.ts | 571 +- .../src/protocols/Aws_restJson1.ts | 382 +- .../src/protocols/Aws_restJson1.ts | 598 ++- .../src/protocols/Aws_restJson1.ts | 49 +- .../src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_json1_1.ts | 436 +- .../src/protocols/Aws_json1_1.ts | 1390 ++--- .../src/protocols/Aws_restJson1.ts | 472 +- .../src/protocols/Aws_json1_0.ts | 220 +- .../src/protocols/Aws_restJson1.ts | 265 +- .../src/protocols/Aws_restJson1.ts | 202 +- .../client-m2/src/protocols/Aws_restJson1.ts | 292 +- .../src/protocols/Aws_json1_1.ts | 256 +- .../client-macie/src/protocols/Aws_json1_1.ts | 67 +- .../src/protocols/Aws_restJson1.ts | 517 +- .../src/protocols/Aws_restJson1.ts | 211 +- .../src/protocols/Aws_restJson1.ts | 58 +- .../src/protocols/Aws_json1_1.ts | 22 +- .../src/protocols/Aws_json1_1.ts | 13 +- .../src/protocols/Aws_json1_1.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 274 +- .../src/protocols/Aws_restJson1.ts | 256 +- .../src/protocols/Aws_restJson1.ts | 517 +- .../src/protocols/Aws_restJson1.ts | 157 +- .../src/protocols/Aws_restJson1.ts | 175 +- .../src/protocols/Aws_restJson1.ts | 49 +- .../src/protocols/Aws_json1_1.ts | 193 +- .../src/protocols/Aws_restJson1.ts | 382 +- .../src/protocols/Aws_json1_1.ts | 319 +- .../client-mgn/src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_restJson1.ts | 220 +- .../src/protocols/Aws_json1_1.ts | 157 +- .../src/protocols/Aws_json1_1.ts | 31 +- .../src/protocols/Aws_restJson1.ts | 184 +- .../src/protocols/Aws_restJson1.ts | 85 +- .../client-mq/src/protocols/Aws_restJson1.ts | 202 +- .../client-mturk/src/protocols/Aws_json1_1.ts | 355 +- .../src/protocols/Aws_restJson1.ts | 103 +- .../client-neptune/src/protocols/Aws_query.ts | 624 ++- .../src/protocols/Aws_json1_0.ts | 283 +- .../src/protocols/Aws_restJson1.ts | 706 +-- .../src/protocols/Aws_restJson1.ts | 427 +- .../src/protocols/Aws_restJson1.ts | 364 +- .../src/protocols/Aws_json1_1.ts | 670 +-- .../src/protocols/Aws_json1_1.ts | 175 +- .../src/protocols/Aws_json1_1.ts | 472 +- .../src/protocols/Aws_restJson1.ts | 238 +- .../src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_restJson1.ts | 31 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_json1_1.ts | 544 +- .../client-pi/src/protocols/Aws_json1_1.ts | 58 +- .../src/protocols/Aws_restJson1.ts | 382 +- .../src/protocols/Aws_json1_0.ts | 391 +- .../src/protocols/Aws_restJson1.ts | 76 +- .../src/protocols/Aws_restJson1.ts | 1075 ++-- .../src/protocols/Aws_restJson1.ts | 85 +- .../src/protocols/Aws_json1_1.ts | 31 +- .../src/protocols/Aws_json1_0.ts | 679 +-- .../src/protocols/Aws_json1_0.ts | 13 +- .../src/protocols/Aws_restJson1.ts | 184 +- .../src/protocols/Aws_restJson1.ts | 1066 ++-- .../client-ram/src/protocols/Aws_restJson1.ts | 229 +- .../src/protocols/Aws_restJson1.ts | 76 +- .../src/protocols/Aws_restJson1.ts | 58 +- clients/client-rds/src/protocols/Aws_query.ts | 1218 +++-- .../src/protocols/Aws_json1_1.ts | 94 +- .../src/protocols/Aws_query.ts | 1074 ++-- .../src/protocols/Aws_json1_1.ts | 535 +- .../src/protocols/Aws_restJson1.ts | 355 +- .../src/protocols/Aws_json1_1.ts | 76 +- .../src/protocols/Aws_restJson1.ts | 148 +- .../src/protocols/Aws_restJson1.ts | 517 +- .../src/protocols/Aws_json1_1.ts | 274 +- .../src/protocols/Aws_restXml.ts | 633 ++- .../src/protocols/Aws_json1_0.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 211 +- .../src/protocols/Aws_restJson1.ts | 292 +- .../src/protocols/Aws_json1_1.ts | 571 +- .../client-rum/src/protocols/Aws_restJson1.ts | 94 +- .../src/protocols/Aws_restXml.ts | 516 +- .../client-s3/src/protocols/Aws_restXml.ts | 840 +-- .../src/protocols/Aws_restJson1.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 49 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_restJson1.ts | 40 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_json1_1.ts | 2263 ++++---- .../src/protocols/Aws_restJson1.ts | 85 +- .../src/protocols/Aws_restJson1.ts | 283 +- .../src/protocols/Aws_json1_1.ts | 202 +- .../src/protocols/Aws_restJson1.ts | 508 +- .../src/protocols/Aws_restJson1.ts | 130 +- .../src/protocols/Aws_restJson1.ts | 202 +- .../src/protocols/Aws_json1_1.ts | 787 +-- .../src/protocols/Aws_json1_1.ts | 175 +- .../src/protocols/Aws_json1_1.ts | 238 +- clients/client-ses/src/protocols/Aws_query.ts | 642 ++- .../src/protocols/Aws_restJson1.ts | 733 +-- .../client-sfn/src/protocols/Aws_json1_0.ts | 211 +- .../src/protocols/Aws_json1_1.ts | 328 +- .../src/protocols/Aws_restJson1.ts | 157 +- .../client-sms/src/protocols/Aws_json1_1.ts | 319 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_json1_1.ts | 229 +- clients/client-sns/src/protocols/Aws_query.ts | 363 +- clients/client-sqs/src/protocols/Aws_query.ts | 183 +- .../src/protocols/Aws_json1_1.ts | 247 +- .../src/protocols/Aws_restJson1.ts | 265 +- .../client-ssm/src/protocols/Aws_json1_1.ts | 1219 +++-- .../src/protocols/Aws_json1_1.ts | 283 +- .../src/protocols/Aws_restJson1.ts | 31 +- .../client-sso/src/protocols/Aws_restJson1.ts | 40 +- .../src/protocols/Aws_json1_1.ts | 814 +-- clients/client-sts/src/protocols/Aws_query.ts | 75 +- .../src/protocols/Aws_json1_1.ts | 130 +- .../client-swf/src/protocols/Aws_json1_0.ts | 337 +- .../src/protocols/Aws_restJson1.ts | 121 +- .../src/protocols/Aws_json1_1.ts | 94 +- .../src/protocols/Aws_json1_0.ts | 121 +- .../src/protocols/Aws_json1_0.ts | 139 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_json1_1.ts | 355 +- .../src/protocols/Aws_json1_1.ts | 292 +- .../src/protocols/Aws_json1_1.ts | 130 +- .../src/protocols/Aws_json1_0.ts | 193 +- .../src/protocols/Aws_json1_1.ts | 733 +-- .../client-waf/src/protocols/Aws_json1_1.ts | 697 +-- .../client-wafv2/src/protocols/Aws_json1_1.ts | 436 +- .../src/protocols/Aws_restJson1.ts | 355 +- .../src/protocols/Aws_restJson1.ts | 283 +- .../src/protocols/Aws_restJson1.ts | 373 +- .../src/protocols/Aws_restJson1.ts | 301 +- .../src/protocols/Aws_json1_1.ts | 616 ++- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_restJson1.ts | 400 +- .../src/protocols/Aws_json1_1.ts | 553 +- .../src/protocols/Aws_restJson1.ts | 247 +- .../src/protocols/Aws_restJson1.ts | 22 +- .../src/protocols/Aws_ec2.ts | 192 +- .../src/protocols/Aws_json1_0.ts | 85 +- .../src/protocols/Aws_json1_1.ts | 112 +- .../src/protocols/Aws_query.ts | 264 +- .../src/protocols/Aws_restJson1.ts | 778 +-- .../src/protocols/Aws_restXml.ts | 480 +- 314 files changed, 59504 insertions(+), 48269 deletions(-) diff --git a/clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts b/clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts index 15b02994d0d65..9c9b71000b4e2 100644 --- a/clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts +++ b/clients/client-accessanalyzer/src/protocols/Aws_restJson1.ts @@ -1041,8 +1041,7 @@ const deserializeAws_restJson1ApplyArchiveRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1061,10 +1060,12 @@ const deserializeAws_restJson1ApplyArchiveRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1094,7 @@ const deserializeAws_restJson1CancelPolicyGenerationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1110,10 +1110,12 @@ const deserializeAws_restJson1CancelPolicyGenerationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1146,8 +1148,7 @@ const deserializeAws_restJson1CreateAccessPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1172,10 +1173,12 @@ const deserializeAws_restJson1CreateAccessPreviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1208,8 +1211,7 @@ const deserializeAws_restJson1CreateAnalyzerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1231,10 +1233,12 @@ const deserializeAws_restJson1CreateAnalyzerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1263,8 +1267,7 @@ const deserializeAws_restJson1CreateArchiveRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1289,10 +1292,12 @@ const deserializeAws_restJson1CreateArchiveRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1321,8 +1326,7 @@ const deserializeAws_restJson1DeleteAnalyzerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1341,10 +1345,12 @@ const deserializeAws_restJson1DeleteAnalyzerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1373,8 +1379,7 @@ const deserializeAws_restJson1DeleteArchiveRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1393,10 +1398,12 @@ const deserializeAws_restJson1DeleteArchiveRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1429,8 +1436,7 @@ const deserializeAws_restJson1GetAccessPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1449,10 +1455,12 @@ const deserializeAws_restJson1GetAccessPreviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1485,8 +1493,7 @@ const deserializeAws_restJson1GetAnalyzedResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1505,10 +1512,12 @@ const deserializeAws_restJson1GetAnalyzedResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1541,8 +1550,7 @@ const deserializeAws_restJson1GetAnalyzerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1561,10 +1569,12 @@ const deserializeAws_restJson1GetAnalyzerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1597,8 +1607,7 @@ const deserializeAws_restJson1GetArchiveRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1617,10 +1626,12 @@ const deserializeAws_restJson1GetArchiveRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1653,8 +1664,7 @@ const deserializeAws_restJson1GetFindingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1673,10 +1683,12 @@ const deserializeAws_restJson1GetFindingCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1713,8 +1725,7 @@ const deserializeAws_restJson1GetGeneratedPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1730,10 +1741,12 @@ const deserializeAws_restJson1GetGeneratedPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1770,8 +1783,7 @@ const deserializeAws_restJson1ListAccessPreviewFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1793,10 +1805,12 @@ const deserializeAws_restJson1ListAccessPreviewFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1833,8 +1847,7 @@ const deserializeAws_restJson1ListAccessPreviewsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1853,10 +1866,12 @@ const deserializeAws_restJson1ListAccessPreviewsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1893,8 +1908,7 @@ const deserializeAws_restJson1ListAnalyzedResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1913,10 +1927,12 @@ const deserializeAws_restJson1ListAnalyzedResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,8 +1969,7 @@ const deserializeAws_restJson1ListAnalyzersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -1970,10 +1985,12 @@ const deserializeAws_restJson1ListAnalyzersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2010,8 +2027,7 @@ const deserializeAws_restJson1ListArchiveRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2027,10 +2043,12 @@ const deserializeAws_restJson1ListArchiveRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2085,7 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2087,10 +2104,12 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2127,8 +2146,7 @@ const deserializeAws_restJson1ListPolicyGenerationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2144,10 +2162,12 @@ const deserializeAws_restJson1ListPolicyGenerationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2180,8 +2200,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2200,10 +2219,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2236,8 +2257,7 @@ const deserializeAws_restJson1StartPolicyGenerationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2259,10 +2279,12 @@ const deserializeAws_restJson1StartPolicyGenerationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2291,8 +2313,7 @@ const deserializeAws_restJson1StartResourceScanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2311,10 +2332,12 @@ const deserializeAws_restJson1StartResourceScanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2343,8 +2366,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2363,10 +2385,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2395,8 +2419,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2415,10 +2438,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2447,8 +2472,7 @@ const deserializeAws_restJson1UpdateArchiveRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2467,10 +2491,12 @@ const deserializeAws_restJson1UpdateArchiveRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2499,8 +2525,7 @@ const deserializeAws_restJson1UpdateFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2519,10 +2544,12 @@ const deserializeAws_restJson1UpdateFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2586,7 @@ const deserializeAws_restJson1ValidatePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.accessanalyzer#AccessDeniedException": @@ -2576,10 +2602,12 @@ const deserializeAws_restJson1ValidatePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4203,7 +4231,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4229,6 +4257,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-account/src/protocols/Aws_restJson1.ts b/clients/client-account/src/protocols/Aws_restJson1.ts index 00eac88df1395..3576392c801c9 100644 --- a/clients/client-account/src/protocols/Aws_restJson1.ts +++ b/clients/client-account/src/protocols/Aws_restJson1.ts @@ -140,8 +140,7 @@ const deserializeAws_restJson1DeleteAlternateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.account#AccessDeniedException": @@ -160,10 +159,12 @@ const deserializeAws_restJson1DeleteAlternateContactCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -196,8 +197,7 @@ const deserializeAws_restJson1GetAlternateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.account#AccessDeniedException": @@ -216,10 +216,12 @@ const deserializeAws_restJson1GetAlternateContactCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -248,8 +250,7 @@ const deserializeAws_restJson1PutAlternateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.account#AccessDeniedException": @@ -265,10 +266,12 @@ const deserializeAws_restJson1PutAlternateContactCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -401,7 +404,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -427,6 +430,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-acm-pca/src/protocols/Aws_json1_1.ts b/clients/client-acm-pca/src/protocols/Aws_json1_1.ts index eb7d9abcdf625..be0e68b55cd6d 100644 --- a/clients/client-acm-pca/src/protocols/Aws_json1_1.ts +++ b/clients/client-acm-pca/src/protocols/Aws_json1_1.ts @@ -486,8 +486,7 @@ const deserializeAws_json1_1CreateCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgsException": case "com.amazonaws.acmpca#InvalidArgsException": @@ -503,10 +502,12 @@ const deserializeAws_json1_1CreateCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -538,8 +539,7 @@ const deserializeAws_json1_1CreateCertificateAuthorityAuditReportCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgsException": case "com.amazonaws.acmpca#InvalidArgsException": @@ -561,10 +561,12 @@ const deserializeAws_json1_1CreateCertificateAuthorityAuditReportCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -593,8 +595,7 @@ const deserializeAws_json1_1CreatePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -616,10 +617,12 @@ const deserializeAws_json1_1CreatePermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -648,8 +651,7 @@ const deserializeAws_json1_1DeleteCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.acmpca#ConcurrentModificationException": @@ -665,10 +667,12 @@ const deserializeAws_json1_1DeleteCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -697,8 +701,7 @@ const deserializeAws_json1_1DeletePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -714,10 +717,12 @@ const deserializeAws_json1_1DeletePermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -746,8 +751,7 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.acmpca#ConcurrentModificationException": @@ -769,10 +773,12 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -804,8 +810,7 @@ const deserializeAws_json1_1DescribeCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -815,10 +820,12 @@ const deserializeAws_json1_1DescribeCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -850,8 +857,7 @@ const deserializeAws_json1_1DescribeCertificateAuthorityAuditReportCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgsException": case "com.amazonaws.acmpca#InvalidArgsException": @@ -864,10 +870,12 @@ const deserializeAws_json1_1DescribeCertificateAuthorityAuditReportCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -899,8 +907,7 @@ const deserializeAws_json1_1GetCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -919,10 +926,12 @@ const deserializeAws_json1_1GetCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -954,8 +963,7 @@ const deserializeAws_json1_1GetCertificateAuthorityCertificateCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -968,10 +976,12 @@ const deserializeAws_json1_1GetCertificateAuthorityCertificateCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1003,8 +1013,7 @@ const deserializeAws_json1_1GetCertificateAuthorityCsrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1023,10 +1032,12 @@ const deserializeAws_json1_1GetCertificateAuthorityCsrCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1058,8 +1069,7 @@ const deserializeAws_json1_1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1075,10 +1085,12 @@ const deserializeAws_json1_1GetPolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1107,8 +1119,7 @@ const deserializeAws_json1_1ImportCertificateAuthorityCertificateCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateMismatchException": case "com.amazonaws.acmpca#CertificateMismatchException": @@ -1139,10 +1150,12 @@ const deserializeAws_json1_1ImportCertificateAuthorityCertificateCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1174,8 +1187,7 @@ const deserializeAws_json1_1IssueCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgsException": case "com.amazonaws.acmpca#InvalidArgsException": @@ -1197,10 +1209,12 @@ const deserializeAws_json1_1IssueCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1232,18 +1246,19 @@ const deserializeAws_json1_1ListCertificateAuthoritiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.acmpca#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1275,8 +1290,7 @@ const deserializeAws_json1_1ListPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1295,10 +1309,12 @@ const deserializeAws_json1_1ListPermissionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1330,8 +1346,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1344,10 +1359,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1376,8 +1393,7 @@ const deserializeAws_json1_1PutPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.acmpca#ConcurrentModificationException": @@ -1402,10 +1418,12 @@ const deserializeAws_json1_1PutPolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1434,8 +1452,7 @@ const deserializeAws_json1_1RestoreCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1448,10 +1465,12 @@ const deserializeAws_json1_1RestoreCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1480,8 +1499,7 @@ const deserializeAws_json1_1RevokeCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.acmpca#ConcurrentModificationException": @@ -1512,10 +1530,12 @@ const deserializeAws_json1_1RevokeCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1564,7 @@ const deserializeAws_json1_1TagCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1564,10 +1583,12 @@ const deserializeAws_json1_1TagCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1596,8 +1617,7 @@ const deserializeAws_json1_1UntagCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acmpca#InvalidArnException": @@ -1613,10 +1633,12 @@ const deserializeAws_json1_1UntagCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1645,8 +1667,7 @@ const deserializeAws_json1_1UpdateCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.acmpca#ConcurrentModificationException": @@ -1668,10 +1689,12 @@ const deserializeAws_json1_1UpdateCertificateAuthorityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3166,7 +3189,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3192,6 +3215,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-acm/src/protocols/Aws_json1_1.ts b/clients/client-acm/src/protocols/Aws_json1_1.ts index ba4c09de77e27..519dca29eb55d 100644 --- a/clients/client-acm/src/protocols/Aws_json1_1.ts +++ b/clients/client-acm/src/protocols/Aws_json1_1.ts @@ -329,8 +329,7 @@ const deserializeAws_json1_1AddTagsToCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -355,10 +354,12 @@ const deserializeAws_json1_1AddTagsToCertificateCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -387,8 +388,7 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -401,10 +401,12 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -436,8 +438,7 @@ const deserializeAws_json1_1DescribeCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -447,10 +448,12 @@ const deserializeAws_json1_1DescribeCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -482,8 +485,7 @@ const deserializeAws_json1_1ExportCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -496,10 +498,12 @@ const deserializeAws_json1_1ExportCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -531,8 +535,7 @@ const deserializeAws_json1_1GetAccountConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.acm#AccessDeniedException": @@ -542,10 +545,12 @@ const deserializeAws_json1_1GetAccountConfigurationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -577,8 +582,7 @@ const deserializeAws_json1_1GetCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -591,10 +595,12 @@ const deserializeAws_json1_1GetCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -626,8 +632,7 @@ const deserializeAws_json1_1ImportCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -652,10 +657,12 @@ const deserializeAws_json1_1ImportCertificateCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -687,18 +694,19 @@ const deserializeAws_json1_1ListCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgsException": case "com.amazonaws.acm#InvalidArgsException": throw await deserializeAws_json1_1InvalidArgsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -730,8 +738,7 @@ const deserializeAws_json1_1ListTagsForCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -741,10 +748,12 @@ const deserializeAws_json1_1ListTagsForCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -773,8 +782,7 @@ const deserializeAws_json1_1PutAccountConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.acm#AccessDeniedException": @@ -790,10 +798,12 @@ const deserializeAws_json1_1PutAccountConfigurationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -822,8 +832,7 @@ const deserializeAws_json1_1RemoveTagsFromCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -845,10 +854,12 @@ const deserializeAws_json1_1RemoveTagsFromCertificateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -877,8 +888,7 @@ const deserializeAws_json1_1RenewCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -888,10 +898,12 @@ const deserializeAws_json1_1RenewCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -923,8 +935,7 @@ const deserializeAws_json1_1RequestCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -949,10 +960,12 @@ const deserializeAws_json1_1RequestCertificateCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -981,8 +994,7 @@ const deserializeAws_json1_1ResendValidationEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -998,10 +1010,12 @@ const deserializeAws_json1_1ResendValidationEmailCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1030,8 +1044,7 @@ const deserializeAws_json1_1UpdateCertificateOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.acm#InvalidArnException": @@ -1047,10 +1060,12 @@ const deserializeAws_json1_1UpdateCertificateOptionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2066,7 +2081,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2092,6 +2107,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts b/clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts index 2e50f6b46d195..53f11b8092d18 100644 --- a/clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts +++ b/clients/client-alexa-for-business/src/protocols/Aws_json1_1.ts @@ -1730,8 +1730,7 @@ const deserializeAws_json1_1ApproveSkillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -1744,10 +1743,12 @@ const deserializeAws_json1_1ApproveSkillCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1779,18 +1780,19 @@ const deserializeAws_json1_1AssociateContactWithAddressBookCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.alexaforbusiness#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1822,8 +1824,7 @@ const deserializeAws_json1_1AssociateDeviceWithNetworkProfileCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -1836,10 +1837,12 @@ const deserializeAws_json1_1AssociateDeviceWithNetworkProfileCommandError = asyn throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1871,8 +1874,7 @@ const deserializeAws_json1_1AssociateDeviceWithRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -1885,10 +1887,12 @@ const deserializeAws_json1_1AssociateDeviceWithRoomCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1920,18 +1924,19 @@ const deserializeAws_json1_1AssociateSkillGroupWithRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1963,8 +1968,7 @@ const deserializeAws_json1_1AssociateSkillWithSkillGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -1977,10 +1981,12 @@ const deserializeAws_json1_1AssociateSkillWithSkillGroupCommandError = async ( throw await deserializeAws_json1_1SkillNotLinkedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2012,8 +2018,7 @@ const deserializeAws_json1_1AssociateSkillWithUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2023,10 +2028,12 @@ const deserializeAws_json1_1AssociateSkillWithUsersCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2058,8 +2065,7 @@ const deserializeAws_json1_1CreateAddressBookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2069,10 +2075,12 @@ const deserializeAws_json1_1CreateAddressBookCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2104,18 +2112,19 @@ const deserializeAws_json1_1CreateBusinessReportScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": throw await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2147,18 +2156,19 @@ const deserializeAws_json1_1CreateConferenceProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": throw await deserializeAws_json1_1AlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2190,8 +2200,7 @@ const deserializeAws_json1_1CreateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2201,10 +2210,12 @@ const deserializeAws_json1_1CreateContactCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2236,8 +2247,7 @@ const deserializeAws_json1_1CreateGatewayGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2247,10 +2257,12 @@ const deserializeAws_json1_1CreateGatewayGroupCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2282,8 +2294,7 @@ const deserializeAws_json1_1CreateNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2302,10 +2313,12 @@ const deserializeAws_json1_1CreateNetworkProfileCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2337,8 +2350,7 @@ const deserializeAws_json1_1CreateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2351,10 +2363,12 @@ const deserializeAws_json1_1CreateProfileCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2400,7 @@ const deserializeAws_json1_1CreateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2397,10 +2410,12 @@ const deserializeAws_json1_1CreateRoomCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2432,8 +2447,7 @@ const deserializeAws_json1_1CreateSkillGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -2446,10 +2460,12 @@ const deserializeAws_json1_1CreateSkillGroupCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2481,8 +2497,7 @@ const deserializeAws_json1_1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2495,10 +2510,12 @@ const deserializeAws_json1_1CreateUserCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2530,8 +2547,7 @@ const deserializeAws_json1_1DeleteAddressBookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2541,10 +2557,12 @@ const deserializeAws_json1_1DeleteAddressBookCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2576,8 +2594,7 @@ const deserializeAws_json1_1DeleteBusinessReportScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2587,10 +2604,12 @@ const deserializeAws_json1_1DeleteBusinessReportScheduleCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2622,18 +2641,19 @@ const deserializeAws_json1_1DeleteConferenceProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2665,8 +2685,7 @@ const deserializeAws_json1_1DeleteContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2676,10 +2695,12 @@ const deserializeAws_json1_1DeleteContactCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2711,8 +2732,7 @@ const deserializeAws_json1_1DeleteDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2725,10 +2745,12 @@ const deserializeAws_json1_1DeleteDeviceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2760,8 +2782,7 @@ const deserializeAws_json1_1DeleteDeviceUsageDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeviceNotRegisteredException": case "com.amazonaws.alexaforbusiness#DeviceNotRegisteredException": @@ -2774,10 +2795,12 @@ const deserializeAws_json1_1DeleteDeviceUsageDataCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2809,18 +2832,19 @@ const deserializeAws_json1_1DeleteGatewayGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceAssociatedException": case "com.amazonaws.alexaforbusiness#ResourceAssociatedException": throw await deserializeAws_json1_1ResourceAssociatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2852,8 +2876,7 @@ const deserializeAws_json1_1DeleteNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2866,10 +2889,12 @@ const deserializeAws_json1_1DeleteNetworkProfileCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2901,8 +2926,7 @@ const deserializeAws_json1_1DeleteProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2912,10 +2936,12 @@ const deserializeAws_json1_1DeleteProfileCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2947,8 +2973,7 @@ const deserializeAws_json1_1DeleteRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -2958,10 +2983,12 @@ const deserializeAws_json1_1DeleteRoomCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2993,18 +3020,19 @@ const deserializeAws_json1_1DeleteRoomSkillParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3036,8 +3064,7 @@ const deserializeAws_json1_1DeleteSkillAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3047,10 +3074,12 @@ const deserializeAws_json1_1DeleteSkillAuthorizationCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3082,8 +3111,7 @@ const deserializeAws_json1_1DeleteSkillGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3093,10 +3121,12 @@ const deserializeAws_json1_1DeleteSkillGroupCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3128,8 +3158,7 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3139,10 +3168,12 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3174,15 +3205,16 @@ const deserializeAws_json1_1DisassociateContactFromAddressBookCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3214,8 +3246,7 @@ const deserializeAws_json1_1DisassociateDeviceFromRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3225,10 +3256,12 @@ const deserializeAws_json1_1DisassociateDeviceFromRoomCommandError = async ( throw await deserializeAws_json1_1DeviceNotRegisteredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3260,8 +3293,7 @@ const deserializeAws_json1_1DisassociateSkillFromSkillGroupCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3271,10 +3303,12 @@ const deserializeAws_json1_1DisassociateSkillFromSkillGroupCommandError = async throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3306,8 +3340,7 @@ const deserializeAws_json1_1DisassociateSkillFromUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -3317,10 +3350,12 @@ const deserializeAws_json1_1DisassociateSkillFromUsersCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3352,18 +3387,19 @@ const deserializeAws_json1_1DisassociateSkillGroupFromRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3395,18 +3431,19 @@ const deserializeAws_json1_1ForgetSmartHomeAppliancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3438,18 +3475,19 @@ const deserializeAws_json1_1GetAddressBookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3481,18 +3519,19 @@ const deserializeAws_json1_1GetConferencePreferenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3524,18 +3563,19 @@ const deserializeAws_json1_1GetConferenceProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3567,18 +3607,19 @@ const deserializeAws_json1_1GetContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3610,18 +3651,19 @@ const deserializeAws_json1_1GetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3653,18 +3695,19 @@ const deserializeAws_json1_1GetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3696,18 +3739,19 @@ const deserializeAws_json1_1GetGatewayGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3739,18 +3783,19 @@ const deserializeAws_json1_1GetInvitationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3782,8 +3827,7 @@ const deserializeAws_json1_1GetNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSecretsManagerResourceException": case "com.amazonaws.alexaforbusiness#InvalidSecretsManagerResourceException": @@ -3793,10 +3837,12 @@ const deserializeAws_json1_1GetNetworkProfileCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3828,18 +3874,19 @@ const deserializeAws_json1_1GetProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3871,18 +3918,19 @@ const deserializeAws_json1_1GetRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3914,18 +3962,19 @@ const deserializeAws_json1_1GetRoomSkillParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3957,18 +4006,19 @@ const deserializeAws_json1_1GetSkillGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4000,15 +4050,16 @@ const deserializeAws_json1_1ListBusinessReportSchedulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4040,15 +4091,16 @@ const deserializeAws_json1_1ListConferenceProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4080,18 +4132,19 @@ const deserializeAws_json1_1ListDeviceEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4123,15 +4176,16 @@ const deserializeAws_json1_1ListGatewayGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4163,15 +4217,16 @@ const deserializeAws_json1_1ListGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4203,15 +4258,16 @@ const deserializeAws_json1_1ListSkillsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4243,15 +4299,16 @@ const deserializeAws_json1_1ListSkillsStoreCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4283,15 +4340,16 @@ const deserializeAws_json1_1ListSkillsStoreSkillsByCategoryCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4323,18 +4381,19 @@ const deserializeAws_json1_1ListSmartHomeAppliancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4366,18 +4425,19 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4409,18 +4469,19 @@ const deserializeAws_json1_1PutConferencePreferenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4452,8 +4513,7 @@ const deserializeAws_json1_1PutInvitationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -4463,10 +4523,12 @@ const deserializeAws_json1_1PutInvitationConfigurationCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4498,18 +4560,19 @@ const deserializeAws_json1_1PutRoomSkillParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4541,8 +4604,7 @@ const deserializeAws_json1_1PutSkillAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -4552,10 +4614,12 @@ const deserializeAws_json1_1PutSkillAuthorizationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4587,8 +4651,7 @@ const deserializeAws_json1_1RegisterAVSDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -4604,10 +4667,12 @@ const deserializeAws_json1_1RegisterAVSDeviceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4639,8 +4704,7 @@ const deserializeAws_json1_1RejectSkillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -4650,10 +4714,12 @@ const deserializeAws_json1_1RejectSkillCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4685,18 +4751,19 @@ const deserializeAws_json1_1ResolveRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4728,8 +4795,7 @@ const deserializeAws_json1_1RevokeInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -4739,10 +4805,12 @@ const deserializeAws_json1_1RevokeInvitationCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4774,15 +4842,16 @@ const deserializeAws_json1_1SearchAddressBooksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4814,15 +4883,16 @@ const deserializeAws_json1_1SearchContactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4854,15 +4924,16 @@ const deserializeAws_json1_1SearchDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4894,15 +4965,16 @@ const deserializeAws_json1_1SearchNetworkProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4934,15 +5006,16 @@ const deserializeAws_json1_1SearchProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4974,15 +5047,16 @@ const deserializeAws_json1_1SearchRoomsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5014,15 +5088,16 @@ const deserializeAws_json1_1SearchSkillGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5054,15 +5129,16 @@ const deserializeAws_json1_1SearchUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5094,8 +5170,7 @@ const deserializeAws_json1_1SendAnnouncementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.alexaforbusiness#AlreadyExistsException": @@ -5105,10 +5180,12 @@ const deserializeAws_json1_1SendAnnouncementCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5140,8 +5217,7 @@ const deserializeAws_json1_1SendInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5154,10 +5230,12 @@ const deserializeAws_json1_1SendInvitationCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5189,18 +5267,19 @@ const deserializeAws_json1_1StartDeviceSyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeviceNotRegisteredException": case "com.amazonaws.alexaforbusiness#DeviceNotRegisteredException": throw await deserializeAws_json1_1DeviceNotRegisteredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5232,18 +5311,19 @@ const deserializeAws_json1_1StartSmartHomeApplianceDiscoveryCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5275,18 +5355,19 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5318,18 +5399,19 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5361,8 +5443,7 @@ const deserializeAws_json1_1UpdateAddressBookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5375,10 +5456,12 @@ const deserializeAws_json1_1UpdateAddressBookCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5410,8 +5493,7 @@ const deserializeAws_json1_1UpdateBusinessReportScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5421,10 +5503,12 @@ const deserializeAws_json1_1UpdateBusinessReportScheduleCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5456,18 +5540,19 @@ const deserializeAws_json1_1UpdateConferenceProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.alexaforbusiness#NotFoundException": throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5499,8 +5584,7 @@ const deserializeAws_json1_1UpdateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5510,10 +5594,12 @@ const deserializeAws_json1_1UpdateContactCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5545,8 +5631,7 @@ const deserializeAws_json1_1UpdateDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5559,10 +5644,12 @@ const deserializeAws_json1_1UpdateDeviceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5594,8 +5681,7 @@ const deserializeAws_json1_1UpdateGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NameInUseException": case "com.amazonaws.alexaforbusiness#NameInUseException": @@ -5605,10 +5691,12 @@ const deserializeAws_json1_1UpdateGatewayCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5640,8 +5728,7 @@ const deserializeAws_json1_1UpdateGatewayGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NameInUseException": case "com.amazonaws.alexaforbusiness#NameInUseException": @@ -5651,10 +5738,12 @@ const deserializeAws_json1_1UpdateGatewayGroupCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5686,8 +5775,7 @@ const deserializeAws_json1_1UpdateNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5706,10 +5794,12 @@ const deserializeAws_json1_1UpdateNetworkProfileCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5741,8 +5831,7 @@ const deserializeAws_json1_1UpdateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5755,10 +5844,12 @@ const deserializeAws_json1_1UpdateProfileCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5790,8 +5881,7 @@ const deserializeAws_json1_1UpdateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NameInUseException": case "com.amazonaws.alexaforbusiness#NameInUseException": @@ -5801,10 +5891,12 @@ const deserializeAws_json1_1UpdateRoomCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5836,8 +5928,7 @@ const deserializeAws_json1_1UpdateSkillGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.alexaforbusiness#ConcurrentModificationException": @@ -5850,10 +5941,12 @@ const deserializeAws_json1_1UpdateSkillGroupCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9338,7 +9431,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9364,6 +9457,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-amp/src/protocols/Aws_restJson1.ts b/clients/client-amp/src/protocols/Aws_restJson1.ts index ed4749b8d098b..d3308192f55b5 100644 --- a/clients/client-amp/src/protocols/Aws_restJson1.ts +++ b/clients/client-amp/src/protocols/Aws_restJson1.ts @@ -692,8 +692,7 @@ const deserializeAws_restJson1CreateAlertManagerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -718,10 +717,12 @@ const deserializeAws_restJson1CreateAlertManagerDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -766,8 +767,7 @@ const deserializeAws_restJson1CreateRuleGroupsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -792,10 +792,12 @@ const deserializeAws_restJson1CreateRuleGroupsNamespaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -840,8 +842,7 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -863,10 +864,12 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -895,8 +898,7 @@ const deserializeAws_restJson1DeleteAlertManagerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -918,10 +920,12 @@ const deserializeAws_restJson1DeleteAlertManagerDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -950,8 +954,7 @@ const deserializeAws_restJson1DeleteRuleGroupsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -973,10 +976,12 @@ const deserializeAws_restJson1DeleteRuleGroupsNamespaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1005,8 +1010,7 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1028,10 +1032,12 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1067,8 +1073,7 @@ const deserializeAws_restJson1DescribeAlertManagerDefinitionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1087,10 +1092,12 @@ const deserializeAws_restJson1DescribeAlertManagerDefinitionCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1126,8 +1133,7 @@ const deserializeAws_restJson1DescribeRuleGroupsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1146,10 +1152,12 @@ const deserializeAws_restJson1DescribeRuleGroupsNamespaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1190,7 @@ const deserializeAws_restJson1DescribeWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1202,10 +1209,12 @@ const deserializeAws_restJson1DescribeWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1245,8 +1254,7 @@ const deserializeAws_restJson1ListRuleGroupsNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1265,10 +1273,12 @@ const deserializeAws_restJson1ListRuleGroupsNamespacesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1301,8 +1311,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1321,10 +1330,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1361,8 +1372,7 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1378,10 +1388,12 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1414,8 +1426,7 @@ const deserializeAws_restJson1PutAlertManagerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1440,10 +1451,12 @@ const deserializeAws_restJson1PutAlertManagerDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1488,8 +1501,7 @@ const deserializeAws_restJson1PutRuleGroupsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1514,10 +1526,12 @@ const deserializeAws_restJson1PutRuleGroupsNamespaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1546,8 +1560,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1566,10 +1579,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1598,8 +1613,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1618,10 +1632,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1650,8 +1666,7 @@ const deserializeAws_restJson1UpdateWorkspaceAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.amp#AccessDeniedException": @@ -1676,10 +1691,12 @@ const deserializeAws_restJson1UpdateWorkspaceAliasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2093,7 +2110,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2119,6 +2136,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-amplify/src/protocols/Aws_restJson1.ts b/clients/client-amplify/src/protocols/Aws_restJson1.ts index 7d7d7c9ff987c..09a7e1a82dbf4 100644 --- a/clients/client-amplify/src/protocols/Aws_restJson1.ts +++ b/clients/client-amplify/src/protocols/Aws_restJson1.ts @@ -1647,8 +1647,7 @@ const deserializeAws_restJson1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1667,10 +1666,12 @@ const deserializeAws_restJson1CreateAppCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1703,8 +1704,7 @@ const deserializeAws_restJson1CreateBackendEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1723,10 +1723,12 @@ const deserializeAws_restJson1CreateBackendEnvironmentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1759,8 +1761,7 @@ const deserializeAws_restJson1CreateBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1782,10 +1783,12 @@ const deserializeAws_restJson1CreateBranchCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1829,7 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1843,10 +1845,12 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1879,8 +1883,7 @@ const deserializeAws_restJson1CreateDomainAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1902,10 +1905,12 @@ const deserializeAws_restJson1CreateDomainAssociationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1938,8 +1943,7 @@ const deserializeAws_restJson1CreateWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -1961,10 +1965,12 @@ const deserializeAws_restJson1CreateWebhookCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1997,8 +2003,7 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2017,10 +2022,12 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2053,8 +2060,7 @@ const deserializeAws_restJson1DeleteBackendEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2073,10 +2079,12 @@ const deserializeAws_restJson1DeleteBackendEnvironmentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2109,8 +2117,7 @@ const deserializeAws_restJson1DeleteBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2129,10 +2136,12 @@ const deserializeAws_restJson1DeleteBranchCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2165,8 +2174,7 @@ const deserializeAws_restJson1DeleteDomainAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2185,10 +2193,12 @@ const deserializeAws_restJson1DeleteDomainAssociationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2221,8 +2231,7 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2241,10 +2250,12 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2277,8 +2288,7 @@ const deserializeAws_restJson1DeleteWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2297,10 +2307,12 @@ const deserializeAws_restJson1DeleteWebhookCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2333,8 +2345,7 @@ const deserializeAws_restJson1GenerateAccessLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2350,10 +2361,12 @@ const deserializeAws_restJson1GenerateAccessLogsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2399,7 @@ const deserializeAws_restJson1GetAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2403,10 +2415,12 @@ const deserializeAws_restJson1GetAppCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2443,8 +2457,7 @@ const deserializeAws_restJson1GetArtifactUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2463,10 +2476,12 @@ const deserializeAws_restJson1GetArtifactUrlCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2499,8 +2514,7 @@ const deserializeAws_restJson1GetBackendEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2516,10 +2530,12 @@ const deserializeAws_restJson1GetBackendEnvironmentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2552,8 +2568,7 @@ const deserializeAws_restJson1GetBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2569,10 +2584,12 @@ const deserializeAws_restJson1GetBranchCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2605,8 +2622,7 @@ const deserializeAws_restJson1GetDomainAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2622,10 +2638,12 @@ const deserializeAws_restJson1GetDomainAssociationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2658,8 +2676,7 @@ const deserializeAws_restJson1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2678,10 +2695,12 @@ const deserializeAws_restJson1GetJobCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2714,8 +2733,7 @@ const deserializeAws_restJson1GetWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2734,10 +2752,12 @@ const deserializeAws_restJson1GetWebhookCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2774,8 +2794,7 @@ const deserializeAws_restJson1ListAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2788,10 +2807,12 @@ const deserializeAws_restJson1ListAppsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2828,8 +2849,7 @@ const deserializeAws_restJson1ListArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2845,10 +2865,12 @@ const deserializeAws_restJson1ListArtifactsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2885,8 +2907,7 @@ const deserializeAws_restJson1ListBackendEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2899,10 +2920,12 @@ const deserializeAws_restJson1ListBackendEnvironmentsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2939,8 +2962,7 @@ const deserializeAws_restJson1ListBranchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -2953,10 +2975,12 @@ const deserializeAws_restJson1ListBranchesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2993,8 +3017,7 @@ const deserializeAws_restJson1ListDomainAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3007,10 +3030,12 @@ const deserializeAws_restJson1ListDomainAssociationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3047,8 +3072,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3064,10 +3088,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3100,8 +3126,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3114,10 +3139,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3154,8 +3181,7 @@ const deserializeAws_restJson1ListWebhooksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3171,10 +3197,12 @@ const deserializeAws_restJson1ListWebhooksCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3207,8 +3235,7 @@ const deserializeAws_restJson1StartDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3227,10 +3254,12 @@ const deserializeAws_restJson1StartDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3263,8 +3292,7 @@ const deserializeAws_restJson1StartJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3283,10 +3311,12 @@ const deserializeAws_restJson1StartJobCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3319,8 +3349,7 @@ const deserializeAws_restJson1StopJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3339,10 +3368,12 @@ const deserializeAws_restJson1StopJobCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3371,8 +3402,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3385,10 +3415,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3417,8 +3449,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3431,10 +3462,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3467,8 +3500,7 @@ const deserializeAws_restJson1UpdateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3484,10 +3516,12 @@ const deserializeAws_restJson1UpdateAppCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3520,8 +3554,7 @@ const deserializeAws_restJson1UpdateBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3540,10 +3573,12 @@ const deserializeAws_restJson1UpdateBranchCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3576,8 +3611,7 @@ const deserializeAws_restJson1UpdateDomainAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3596,10 +3630,12 @@ const deserializeAws_restJson1UpdateDomainAssociationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3632,8 +3668,7 @@ const deserializeAws_restJson1UpdateWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplify#BadRequestException": @@ -3652,10 +3687,12 @@ const deserializeAws_restJson1UpdateWebhookCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4438,7 +4475,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4464,6 +4501,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-amplifybackend/src/protocols/Aws_restJson1.ts b/clients/client-amplifybackend/src/protocols/Aws_restJson1.ts index 6d0d5ad31febb..5feedf212ded5 100644 --- a/clients/client-amplifybackend/src/protocols/Aws_restJson1.ts +++ b/clients/client-amplifybackend/src/protocols/Aws_restJson1.ts @@ -1449,8 +1449,7 @@ const deserializeAws_restJson1CloneBackendCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1466,10 +1465,12 @@ const deserializeAws_restJson1CloneBackendCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1522,8 +1523,7 @@ const deserializeAws_restJson1CreateBackendCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1539,10 +1539,12 @@ const deserializeAws_restJson1CreateBackendCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1595,8 +1597,7 @@ const deserializeAws_restJson1CreateBackendAPICommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1612,10 +1613,12 @@ const deserializeAws_restJson1CreateBackendAPICommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1668,8 +1671,7 @@ const deserializeAws_restJson1CreateBackendAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1685,10 +1687,12 @@ const deserializeAws_restJson1CreateBackendAuthCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1733,8 +1737,7 @@ const deserializeAws_restJson1CreateBackendConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1750,10 +1753,12 @@ const deserializeAws_restJson1CreateBackendConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1798,8 +1803,7 @@ const deserializeAws_restJson1CreateBackendStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1815,10 +1819,12 @@ const deserializeAws_restJson1CreateBackendStorageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1863,8 +1869,7 @@ const deserializeAws_restJson1CreateTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1880,10 +1885,12 @@ const deserializeAws_restJson1CreateTokenCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1936,8 +1943,7 @@ const deserializeAws_restJson1DeleteBackendCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -1953,10 +1959,12 @@ const deserializeAws_restJson1DeleteBackendCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2009,8 +2017,7 @@ const deserializeAws_restJson1DeleteBackendAPICommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2026,10 +2033,12 @@ const deserializeAws_restJson1DeleteBackendAPICommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2082,8 +2091,7 @@ const deserializeAws_restJson1DeleteBackendAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2099,10 +2107,12 @@ const deserializeAws_restJson1DeleteBackendAuthCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2147,8 +2157,7 @@ const deserializeAws_restJson1DeleteBackendStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2164,10 +2173,12 @@ const deserializeAws_restJson1DeleteBackendStorageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2200,8 +2211,7 @@ const deserializeAws_restJson1DeleteTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2217,10 +2227,12 @@ const deserializeAws_restJson1DeleteTokenCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,8 +2285,7 @@ const deserializeAws_restJson1GenerateBackendAPIModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2290,10 +2301,12 @@ const deserializeAws_restJson1GenerateBackendAPIModelsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2350,8 +2363,7 @@ const deserializeAws_restJson1GetBackendCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2367,10 +2379,12 @@ const deserializeAws_restJson1GetBackendCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2419,8 +2433,7 @@ const deserializeAws_restJson1GetBackendAPICommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2436,10 +2449,12 @@ const deserializeAws_restJson1GetBackendAPICommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2476,8 +2491,7 @@ const deserializeAws_restJson1GetBackendAPIModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2493,10 +2507,12 @@ const deserializeAws_restJson1GetBackendAPIModelsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2545,8 +2561,7 @@ const deserializeAws_restJson1GetBackendAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2562,10 +2577,12 @@ const deserializeAws_restJson1GetBackendAuthCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2626,8 +2643,7 @@ const deserializeAws_restJson1GetBackendJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2643,10 +2659,12 @@ const deserializeAws_restJson1GetBackendJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2691,8 +2709,7 @@ const deserializeAws_restJson1GetBackendStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2708,10 +2725,12 @@ const deserializeAws_restJson1GetBackendStorageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2756,8 +2775,7 @@ const deserializeAws_restJson1GetTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2773,10 +2791,12 @@ const deserializeAws_restJson1GetTokenCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2829,8 +2849,7 @@ const deserializeAws_restJson1ImportBackendAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2846,10 +2865,12 @@ const deserializeAws_restJson1ImportBackendAuthCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2894,8 +2915,7 @@ const deserializeAws_restJson1ImportBackendStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2911,10 +2931,12 @@ const deserializeAws_restJson1ImportBackendStorageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2951,8 +2973,7 @@ const deserializeAws_restJson1ListBackendJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -2968,10 +2989,12 @@ const deserializeAws_restJson1ListBackendJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3008,8 +3031,7 @@ const deserializeAws_restJson1ListS3BucketsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3025,10 +3047,12 @@ const deserializeAws_restJson1ListS3BucketsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3077,8 +3101,7 @@ const deserializeAws_restJson1RemoveAllBackendsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3094,10 +3117,12 @@ const deserializeAws_restJson1RemoveAllBackendsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3130,8 +3155,7 @@ const deserializeAws_restJson1RemoveBackendConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3147,10 +3171,12 @@ const deserializeAws_restJson1RemoveBackendConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3203,8 +3229,7 @@ const deserializeAws_restJson1UpdateBackendAPICommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3220,10 +3245,12 @@ const deserializeAws_restJson1UpdateBackendAPICommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3276,8 +3303,7 @@ const deserializeAws_restJson1UpdateBackendAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3293,10 +3319,12 @@ const deserializeAws_restJson1UpdateBackendAuthCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3341,8 +3369,7 @@ const deserializeAws_restJson1UpdateBackendConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3358,10 +3385,12 @@ const deserializeAws_restJson1UpdateBackendConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3422,8 +3451,7 @@ const deserializeAws_restJson1UpdateBackendJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3439,10 +3467,12 @@ const deserializeAws_restJson1UpdateBackendJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3487,8 +3517,7 @@ const deserializeAws_restJson1UpdateBackendStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.amplifybackend#BadRequestException": @@ -3504,10 +3533,12 @@ const deserializeAws_restJson1UpdateBackendStorageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4692,7 +4723,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4718,6 +4749,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-amplifyuibuilder/src/protocols/Aws_restJson1.ts b/clients/client-amplifyuibuilder/src/protocols/Aws_restJson1.ts index 9c491d54dc108..7124ac0116901 100644 --- a/clients/client-amplifyuibuilder/src/protocols/Aws_restJson1.ts +++ b/clients/client-amplifyuibuilder/src/protocols/Aws_restJson1.ts @@ -761,8 +761,7 @@ const deserializeAws_restJson1CreateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -778,10 +777,12 @@ const deserializeAws_restJson1CreateComponentCommandError = async ( throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -812,8 +813,7 @@ const deserializeAws_restJson1CreateThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -829,10 +829,12 @@ const deserializeAws_restJson1CreateThemeCommandError = async ( throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -861,8 +863,7 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -875,10 +876,12 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -907,8 +910,7 @@ const deserializeAws_restJson1DeleteThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -921,10 +923,12 @@ const deserializeAws_restJson1DeleteThemeCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -965,18 +969,19 @@ const deserializeAws_restJson1ExchangeCodeForTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.amplifyuibuilder#InvalidParameterException": throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1013,8 +1018,7 @@ const deserializeAws_restJson1ExportComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1024,10 +1028,12 @@ const deserializeAws_restJson1ExportComponentsCommandError = async ( throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1064,8 +1070,7 @@ const deserializeAws_restJson1ExportThemesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1075,10 +1080,12 @@ const deserializeAws_restJson1ExportThemesCommandError = async ( throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1109,8 +1116,7 @@ const deserializeAws_restJson1GetComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1123,10 +1129,12 @@ const deserializeAws_restJson1GetComponentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1157,8 +1165,7 @@ const deserializeAws_restJson1GetThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1171,10 +1178,12 @@ const deserializeAws_restJson1GetThemeCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1211,8 +1220,7 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1222,10 +1230,12 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1262,8 +1272,7 @@ const deserializeAws_restJson1ListThemesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1273,10 +1282,12 @@ const deserializeAws_restJson1ListThemesCommandError = async ( throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1313,18 +1324,19 @@ const deserializeAws_restJson1RefreshTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.amplifyuibuilder#InvalidParameterException": throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1355,8 +1367,7 @@ const deserializeAws_restJson1UpdateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1369,10 +1380,12 @@ const deserializeAws_restJson1UpdateComponentCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1403,8 +1416,7 @@ const deserializeAws_restJson1UpdateThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.amplifyuibuilder#InternalServerException": @@ -1417,10 +1429,12 @@ const deserializeAws_restJson1UpdateThemeCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2699,7 +2713,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2725,6 +2739,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-api-gateway/src/protocols/Aws_restJson1.ts b/clients/client-api-gateway/src/protocols/Aws_restJson1.ts index 3f2fc23a8803e..8e8282425451c 100644 --- a/clients/client-api-gateway/src/protocols/Aws_restJson1.ts +++ b/clients/client-api-gateway/src/protocols/Aws_restJson1.ts @@ -5210,8 +5210,7 @@ const deserializeAws_restJson1CreateApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5233,10 +5232,12 @@ const deserializeAws_restJson1CreateApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5305,8 +5306,7 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5328,10 +5328,12 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5372,8 +5374,7 @@ const deserializeAws_restJson1CreateBasePathMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5395,10 +5396,12 @@ const deserializeAws_restJson1CreateBasePathMappingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5443,8 +5446,7 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5469,10 +5471,12 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5513,8 +5517,7 @@ const deserializeAws_restJson1CreateDocumentationPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5536,10 +5539,12 @@ const deserializeAws_restJson1CreateDocumentationPartCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5580,8 +5585,7 @@ const deserializeAws_restJson1CreateDocumentationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5603,10 +5607,12 @@ const deserializeAws_restJson1CreateDocumentationVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5706,8 +5712,7 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5726,10 +5731,12 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5778,8 +5785,7 @@ const deserializeAws_restJson1CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5801,10 +5807,12 @@ const deserializeAws_restJson1CreateModelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5849,8 +5857,7 @@ const deserializeAws_restJson1CreateRequestValidatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5872,10 +5879,12 @@ const deserializeAws_restJson1CreateRequestValidatorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5924,8 +5933,7 @@ const deserializeAws_restJson1CreateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -5947,10 +5955,12 @@ const deserializeAws_restJson1CreateResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6031,8 +6041,7 @@ const deserializeAws_restJson1CreateRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6051,10 +6060,12 @@ const deserializeAws_restJson1CreateRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6151,8 +6162,7 @@ const deserializeAws_restJson1CreateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6174,10 +6184,12 @@ const deserializeAws_restJson1CreateStageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6238,8 +6250,7 @@ const deserializeAws_restJson1CreateUsagePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6261,10 +6272,12 @@ const deserializeAws_restJson1CreateUsagePlanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6309,8 +6322,7 @@ const deserializeAws_restJson1CreateUsagePlanKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6332,10 +6344,12 @@ const deserializeAws_restJson1CreateUsagePlanKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6392,8 +6406,7 @@ const deserializeAws_restJson1CreateVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6412,10 +6425,12 @@ const deserializeAws_restJson1CreateVpcLinkCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6444,8 +6459,7 @@ const deserializeAws_restJson1DeleteApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6464,10 +6478,12 @@ const deserializeAws_restJson1DeleteApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6496,8 +6512,7 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6516,10 +6531,12 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6548,8 +6565,7 @@ const deserializeAws_restJson1DeleteBasePathMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6568,10 +6584,12 @@ const deserializeAws_restJson1DeleteBasePathMappingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6600,8 +6618,7 @@ const deserializeAws_restJson1DeleteClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6620,10 +6637,12 @@ const deserializeAws_restJson1DeleteClientCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6652,8 +6671,7 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6675,10 +6693,12 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6707,8 +6727,7 @@ const deserializeAws_restJson1DeleteDocumentationPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6727,10 +6746,12 @@ const deserializeAws_restJson1DeleteDocumentationPartCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6759,8 +6780,7 @@ const deserializeAws_restJson1DeleteDocumentationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6779,10 +6799,12 @@ const deserializeAws_restJson1DeleteDocumentationVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6811,8 +6833,7 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6831,10 +6852,12 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6863,8 +6886,7 @@ const deserializeAws_restJson1DeleteGatewayResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6883,10 +6905,12 @@ const deserializeAws_restJson1DeleteGatewayResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6915,8 +6939,7 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6935,10 +6958,12 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6967,8 +6992,7 @@ const deserializeAws_restJson1DeleteIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -6987,10 +7011,12 @@ const deserializeAws_restJson1DeleteIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7019,8 +7045,7 @@ const deserializeAws_restJson1DeleteMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.apigateway#ConflictException": @@ -7036,10 +7061,12 @@ const deserializeAws_restJson1DeleteMethodCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7068,8 +7095,7 @@ const deserializeAws_restJson1DeleteMethodResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7088,10 +7114,12 @@ const deserializeAws_restJson1DeleteMethodResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7120,8 +7148,7 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7140,10 +7167,12 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7172,8 +7201,7 @@ const deserializeAws_restJson1DeleteRequestValidatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7192,10 +7220,12 @@ const deserializeAws_restJson1DeleteRequestValidatorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7224,8 +7254,7 @@ const deserializeAws_restJson1DeleteResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7244,10 +7273,12 @@ const deserializeAws_restJson1DeleteResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7276,8 +7307,7 @@ const deserializeAws_restJson1DeleteRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7296,10 +7326,12 @@ const deserializeAws_restJson1DeleteRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7328,8 +7360,7 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7351,10 +7382,12 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7383,8 +7416,7 @@ const deserializeAws_restJson1DeleteUsagePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7403,10 +7435,12 @@ const deserializeAws_restJson1DeleteUsagePlanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7435,8 +7469,7 @@ const deserializeAws_restJson1DeleteUsagePlanKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7455,10 +7488,12 @@ const deserializeAws_restJson1DeleteUsagePlanKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7487,8 +7522,7 @@ const deserializeAws_restJson1DeleteVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7507,10 +7541,12 @@ const deserializeAws_restJson1DeleteVpcLinkCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7539,8 +7575,7 @@ const deserializeAws_restJson1FlushStageAuthorizersCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7562,10 +7597,12 @@ const deserializeAws_restJson1FlushStageAuthorizersCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7594,8 +7631,7 @@ const deserializeAws_restJson1FlushStageCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7617,10 +7653,12 @@ const deserializeAws_restJson1FlushStageCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7673,8 +7711,7 @@ const deserializeAws_restJson1GenerateClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7693,10 +7730,12 @@ const deserializeAws_restJson1GenerateClientCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7741,8 +7780,7 @@ const deserializeAws_restJson1GetAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7758,10 +7796,12 @@ const deserializeAws_restJson1GetAccountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7830,8 +7870,7 @@ const deserializeAws_restJson1GetApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7847,10 +7886,12 @@ const deserializeAws_restJson1GetApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7891,8 +7932,7 @@ const deserializeAws_restJson1GetApiKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7908,10 +7948,12 @@ const deserializeAws_restJson1GetApiKeysCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7980,8 +8022,7 @@ const deserializeAws_restJson1GetAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -7997,10 +8038,12 @@ const deserializeAws_restJson1GetAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8037,8 +8080,7 @@ const deserializeAws_restJson1GetAuthorizersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8054,10 +8096,12 @@ const deserializeAws_restJson1GetAuthorizersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8098,8 +8142,7 @@ const deserializeAws_restJson1GetBasePathMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8115,10 +8158,12 @@ const deserializeAws_restJson1GetBasePathMappingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8155,8 +8200,7 @@ const deserializeAws_restJson1GetBasePathMappingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8172,10 +8216,12 @@ const deserializeAws_restJson1GetBasePathMappingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8228,8 +8274,7 @@ const deserializeAws_restJson1GetClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8245,10 +8290,12 @@ const deserializeAws_restJson1GetClientCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8285,8 +8332,7 @@ const deserializeAws_restJson1GetClientCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8302,10 +8348,12 @@ const deserializeAws_restJson1GetClientCertificatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8350,8 +8398,7 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8370,10 +8417,12 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8410,8 +8459,7 @@ const deserializeAws_restJson1GetDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8430,10 +8478,12 @@ const deserializeAws_restJson1GetDeploymentsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8474,8 +8524,7 @@ const deserializeAws_restJson1GetDocumentationPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8491,10 +8540,12 @@ const deserializeAws_restJson1GetDocumentationPartCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8531,8 +8582,7 @@ const deserializeAws_restJson1GetDocumentationPartsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8548,10 +8598,12 @@ const deserializeAws_restJson1GetDocumentationPartsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8592,8 +8644,7 @@ const deserializeAws_restJson1GetDocumentationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigateway#NotFoundException": @@ -8606,10 +8657,12 @@ const deserializeAws_restJson1GetDocumentationVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8646,8 +8699,7 @@ const deserializeAws_restJson1GetDocumentationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8663,10 +8715,12 @@ const deserializeAws_restJson1GetDocumentationVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8766,8 +8820,7 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8783,10 +8836,12 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8823,8 +8878,7 @@ const deserializeAws_restJson1GetDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8840,10 +8894,12 @@ const deserializeAws_restJson1GetDomainNamesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8882,8 +8938,7 @@ const deserializeAws_restJson1GetExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8905,10 +8960,12 @@ const deserializeAws_restJson1GetExportCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8957,8 +9014,7 @@ const deserializeAws_restJson1GetGatewayResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -8974,10 +9030,12 @@ const deserializeAws_restJson1GetGatewayResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9014,8 +9072,7 @@ const deserializeAws_restJson1GetGatewayResponsesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9031,10 +9088,12 @@ const deserializeAws_restJson1GetGatewayResponsesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9126,8 +9185,7 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9143,10 +9201,12 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9195,8 +9255,7 @@ const deserializeAws_restJson1GetIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9212,10 +9271,12 @@ const deserializeAws_restJson1GetIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9288,8 +9349,7 @@ const deserializeAws_restJson1GetMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigateway#NotFoundException": @@ -9302,10 +9362,12 @@ const deserializeAws_restJson1GetMethodCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9346,8 +9408,7 @@ const deserializeAws_restJson1GetMethodResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigateway#NotFoundException": @@ -9360,10 +9421,12 @@ const deserializeAws_restJson1GetMethodResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9412,8 +9475,7 @@ const deserializeAws_restJson1GetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9429,10 +9491,12 @@ const deserializeAws_restJson1GetModelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9469,8 +9533,7 @@ const deserializeAws_restJson1GetModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9486,10 +9549,12 @@ const deserializeAws_restJson1GetModelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9522,8 +9587,7 @@ const deserializeAws_restJson1GetModelTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9539,10 +9603,12 @@ const deserializeAws_restJson1GetModelTemplateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9587,8 +9653,7 @@ const deserializeAws_restJson1GetRequestValidatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9604,10 +9669,12 @@ const deserializeAws_restJson1GetRequestValidatorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9644,8 +9711,7 @@ const deserializeAws_restJson1GetRequestValidatorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9661,10 +9727,12 @@ const deserializeAws_restJson1GetRequestValidatorsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9713,8 +9781,7 @@ const deserializeAws_restJson1GetResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigateway#NotFoundException": @@ -9727,10 +9794,12 @@ const deserializeAws_restJson1GetResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9767,8 +9836,7 @@ const deserializeAws_restJson1GetResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9784,10 +9852,12 @@ const deserializeAws_restJson1GetResourcesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9868,8 +9938,7 @@ const deserializeAws_restJson1GetRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9885,10 +9954,12 @@ const deserializeAws_restJson1GetRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9925,8 +9996,7 @@ const deserializeAws_restJson1GetRestApisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -9942,10 +10012,12 @@ const deserializeAws_restJson1GetRestApisCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9984,8 +10056,7 @@ const deserializeAws_restJson1GetSdkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10007,10 +10078,12 @@ const deserializeAws_restJson1GetSdkCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10058,8 +10131,7 @@ const deserializeAws_restJson1GetSdkTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10075,10 +10147,12 @@ const deserializeAws_restJson1GetSdkTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10111,8 +10185,7 @@ const deserializeAws_restJson1GetSdkTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10128,10 +10201,12 @@ const deserializeAws_restJson1GetSdkTypesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10228,8 +10303,7 @@ const deserializeAws_restJson1GetStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10251,10 +10325,12 @@ const deserializeAws_restJson1GetStageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10287,8 +10363,7 @@ const deserializeAws_restJson1GetStagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10310,10 +10385,12 @@ const deserializeAws_restJson1GetStagesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10346,8 +10423,7 @@ const deserializeAws_restJson1GetTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10363,10 +10439,12 @@ const deserializeAws_restJson1GetTagsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10415,8 +10493,7 @@ const deserializeAws_restJson1GetUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10432,10 +10509,12 @@ const deserializeAws_restJson1GetUsageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10496,8 +10575,7 @@ const deserializeAws_restJson1GetUsagePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10513,10 +10591,12 @@ const deserializeAws_restJson1GetUsagePlanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10561,8 +10641,7 @@ const deserializeAws_restJson1GetUsagePlanKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10578,10 +10657,12 @@ const deserializeAws_restJson1GetUsagePlanKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10618,8 +10699,7 @@ const deserializeAws_restJson1GetUsagePlanKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10635,10 +10715,12 @@ const deserializeAws_restJson1GetUsagePlanKeysCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10675,8 +10757,7 @@ const deserializeAws_restJson1GetUsagePlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10692,10 +10773,12 @@ const deserializeAws_restJson1GetUsagePlansCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10752,8 +10835,7 @@ const deserializeAws_restJson1GetVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10769,10 +10851,12 @@ const deserializeAws_restJson1GetVpcLinkCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10809,8 +10893,7 @@ const deserializeAws_restJson1GetVpcLinksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10826,10 +10909,12 @@ const deserializeAws_restJson1GetVpcLinksCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10866,8 +10951,7 @@ const deserializeAws_restJson1ImportApiKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10889,10 +10973,12 @@ const deserializeAws_restJson1ImportApiKeysCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10929,8 +11015,7 @@ const deserializeAws_restJson1ImportDocumentationPartsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -10952,10 +11037,12 @@ const deserializeAws_restJson1ImportDocumentationPartsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11036,8 +11123,7 @@ const deserializeAws_restJson1ImportRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11059,10 +11145,12 @@ const deserializeAws_restJson1ImportRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11111,8 +11199,7 @@ const deserializeAws_restJson1PutGatewayResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11134,10 +11221,12 @@ const deserializeAws_restJson1PutGatewayResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11229,8 +11318,7 @@ const deserializeAws_restJson1PutIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11252,10 +11340,12 @@ const deserializeAws_restJson1PutIntegrationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11304,8 +11394,7 @@ const deserializeAws_restJson1PutIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11327,10 +11416,12 @@ const deserializeAws_restJson1PutIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11403,8 +11494,7 @@ const deserializeAws_restJson1PutMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11426,10 +11516,12 @@ const deserializeAws_restJson1PutMethodCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11470,8 +11562,7 @@ const deserializeAws_restJson1PutMethodResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11493,10 +11584,12 @@ const deserializeAws_restJson1PutMethodResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11577,8 +11670,7 @@ const deserializeAws_restJson1PutRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11600,10 +11692,12 @@ const deserializeAws_restJson1PutRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11632,8 +11726,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11655,10 +11748,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11715,8 +11810,7 @@ const deserializeAws_restJson1TestInvokeAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11732,10 +11826,12 @@ const deserializeAws_restJson1TestInvokeAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11788,8 +11884,7 @@ const deserializeAws_restJson1TestInvokeMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11805,10 +11900,12 @@ const deserializeAws_restJson1TestInvokeMethodCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11837,8 +11934,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11860,10 +11956,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11908,8 +12006,7 @@ const deserializeAws_restJson1UpdateAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -11931,10 +12028,12 @@ const deserializeAws_restJson1UpdateAccountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12003,8 +12102,7 @@ const deserializeAws_restJson1UpdateApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12026,10 +12124,12 @@ const deserializeAws_restJson1UpdateApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12098,8 +12198,7 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12121,10 +12220,12 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12165,8 +12266,7 @@ const deserializeAws_restJson1UpdateBasePathMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12188,10 +12288,12 @@ const deserializeAws_restJson1UpdateBasePathMappingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12244,8 +12346,7 @@ const deserializeAws_restJson1UpdateClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12267,10 +12368,12 @@ const deserializeAws_restJson1UpdateClientCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12315,8 +12418,7 @@ const deserializeAws_restJson1UpdateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12341,10 +12443,12 @@ const deserializeAws_restJson1UpdateDeploymentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12385,8 +12489,7 @@ const deserializeAws_restJson1UpdateDocumentationPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12408,10 +12511,12 @@ const deserializeAws_restJson1UpdateDocumentationPartCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12452,8 +12557,7 @@ const deserializeAws_restJson1UpdateDocumentationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12475,10 +12579,12 @@ const deserializeAws_restJson1UpdateDocumentationVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12578,8 +12684,7 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12601,10 +12706,12 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12653,8 +12760,7 @@ const deserializeAws_restJson1UpdateGatewayResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12676,10 +12782,12 @@ const deserializeAws_restJson1UpdateGatewayResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12771,8 +12879,7 @@ const deserializeAws_restJson1UpdateIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12794,10 +12901,12 @@ const deserializeAws_restJson1UpdateIntegrationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12846,8 +12955,7 @@ const deserializeAws_restJson1UpdateIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12869,10 +12977,12 @@ const deserializeAws_restJson1UpdateIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12945,8 +13055,7 @@ const deserializeAws_restJson1UpdateMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -12965,10 +13074,12 @@ const deserializeAws_restJson1UpdateMethodCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13009,8 +13120,7 @@ const deserializeAws_restJson1UpdateMethodResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13032,10 +13142,12 @@ const deserializeAws_restJson1UpdateMethodResponseCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13084,8 +13196,7 @@ const deserializeAws_restJson1UpdateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13107,10 +13218,12 @@ const deserializeAws_restJson1UpdateModelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13155,8 +13268,7 @@ const deserializeAws_restJson1UpdateRequestValidatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13178,10 +13290,12 @@ const deserializeAws_restJson1UpdateRequestValidatorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13230,8 +13344,7 @@ const deserializeAws_restJson1UpdateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13250,10 +13363,12 @@ const deserializeAws_restJson1UpdateResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13334,8 +13449,7 @@ const deserializeAws_restJson1UpdateRestApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13357,10 +13471,12 @@ const deserializeAws_restJson1UpdateRestApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13457,8 +13573,7 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13480,10 +13595,12 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13532,8 +13649,7 @@ const deserializeAws_restJson1UpdateUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13555,10 +13671,12 @@ const deserializeAws_restJson1UpdateUsageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13619,8 +13737,7 @@ const deserializeAws_restJson1UpdateUsagePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13642,10 +13759,12 @@ const deserializeAws_restJson1UpdateUsagePlanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13702,8 +13821,7 @@ const deserializeAws_restJson1UpdateVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigateway#BadRequestException": @@ -13725,10 +13843,12 @@ const deserializeAws_restJson1UpdateVpcLinkCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15140,7 +15260,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -15166,6 +15286,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-apigatewaymanagementapi/src/protocols/Aws_restJson1.ts b/clients/client-apigatewaymanagementapi/src/protocols/Aws_restJson1.ts index 05dd8f485262d..8952eadb938eb 100644 --- a/clients/client-apigatewaymanagementapi/src/protocols/Aws_restJson1.ts +++ b/clients/client-apigatewaymanagementapi/src/protocols/Aws_restJson1.ts @@ -141,8 +141,7 @@ const deserializeAws_restJson1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.apigatewaymanagementapi#ForbiddenException": @@ -155,10 +154,12 @@ const deserializeAws_restJson1DeleteConnectionCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -199,8 +200,7 @@ const deserializeAws_restJson1GetConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.apigatewaymanagementapi#ForbiddenException": @@ -213,10 +213,12 @@ const deserializeAws_restJson1GetConnectionCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -245,8 +247,7 @@ const deserializeAws_restJson1PostToConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.apigatewaymanagementapi#ForbiddenException": @@ -262,10 +263,12 @@ const deserializeAws_restJson1PostToConnectionCommandError = async ( throw await deserializeAws_restJson1PayloadTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -370,7 +373,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -396,6 +399,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-apigatewayv2/src/protocols/Aws_restJson1.ts b/clients/client-apigatewayv2/src/protocols/Aws_restJson1.ts index 6c3b5cdb002cb..54aaf7cb8c81f 100644 --- a/clients/client-apigatewayv2/src/protocols/Aws_restJson1.ts +++ b/clients/client-apigatewayv2/src/protocols/Aws_restJson1.ts @@ -3248,8 +3248,7 @@ const deserializeAws_restJson1CreateApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3265,10 +3264,12 @@ const deserializeAws_restJson1CreateApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3313,8 +3314,7 @@ const deserializeAws_restJson1CreateApiMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3330,10 +3330,12 @@ const deserializeAws_restJson1CreateApiMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3406,8 +3408,7 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3423,10 +3424,12 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3479,8 +3482,7 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3496,10 +3498,12 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3554,8 +3558,7 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.apigatewayv2#AccessDeniedException": @@ -3574,10 +3577,12 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3689,8 +3694,7 @@ const deserializeAws_restJson1CreateIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3706,10 +3710,12 @@ const deserializeAws_restJson1CreateIntegrationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3762,8 +3768,7 @@ const deserializeAws_restJson1CreateIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3779,10 +3784,12 @@ const deserializeAws_restJson1CreateIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3831,8 +3838,7 @@ const deserializeAws_restJson1CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3848,10 +3854,12 @@ const deserializeAws_restJson1CreateModelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3932,8 +3940,7 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -3949,10 +3956,12 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4001,8 +4010,7 @@ const deserializeAws_restJson1CreateRouteResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -4018,10 +4026,12 @@ const deserializeAws_restJson1CreateRouteResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4106,8 +4116,7 @@ const deserializeAws_restJson1CreateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -4123,10 +4132,12 @@ const deserializeAws_restJson1CreateStageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4191,8 +4202,7 @@ const deserializeAws_restJson1CreateVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -4202,10 +4212,12 @@ const deserializeAws_restJson1CreateVpcLinkCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4234,8 +4246,7 @@ const deserializeAws_restJson1DeleteAccessLogSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4245,10 +4256,12 @@ const deserializeAws_restJson1DeleteAccessLogSettingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4277,8 +4290,7 @@ const deserializeAws_restJson1DeleteApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4288,10 +4300,12 @@ const deserializeAws_restJson1DeleteApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4320,8 +4334,7 @@ const deserializeAws_restJson1DeleteApiMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -4334,10 +4347,12 @@ const deserializeAws_restJson1DeleteApiMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4366,8 +4381,7 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4377,10 +4391,12 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4409,8 +4425,7 @@ const deserializeAws_restJson1DeleteCorsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4420,10 +4435,12 @@ const deserializeAws_restJson1DeleteCorsConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4452,8 +4469,7 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4463,10 +4479,12 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4495,8 +4513,7 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4506,10 +4523,12 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4538,8 +4557,7 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4549,10 +4567,12 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4581,8 +4601,7 @@ const deserializeAws_restJson1DeleteIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4592,10 +4611,12 @@ const deserializeAws_restJson1DeleteIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4624,8 +4645,7 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4635,10 +4655,12 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4667,8 +4689,7 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4678,10 +4699,12 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4710,8 +4733,7 @@ const deserializeAws_restJson1DeleteRouteRequestParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4721,10 +4743,12 @@ const deserializeAws_restJson1DeleteRouteRequestParameterCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4753,8 +4777,7 @@ const deserializeAws_restJson1DeleteRouteResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4764,10 +4787,12 @@ const deserializeAws_restJson1DeleteRouteResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4796,8 +4821,7 @@ const deserializeAws_restJson1DeleteRouteSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4807,10 +4831,12 @@ const deserializeAws_restJson1DeleteRouteSettingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4839,8 +4865,7 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4850,10 +4875,12 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4882,8 +4909,7 @@ const deserializeAws_restJson1DeleteVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -4893,10 +4919,12 @@ const deserializeAws_restJson1DeleteVpcLinkCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4927,8 +4955,7 @@ const deserializeAws_restJson1ExportApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -4941,10 +4968,12 @@ const deserializeAws_restJson1ExportApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5037,8 +5066,7 @@ const deserializeAws_restJson1GetApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5048,10 +5076,12 @@ const deserializeAws_restJson1GetApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5096,8 +5126,7 @@ const deserializeAws_restJson1GetApiMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5110,10 +5139,12 @@ const deserializeAws_restJson1GetApiMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5150,8 +5181,7 @@ const deserializeAws_restJson1GetApiMappingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5164,10 +5194,12 @@ const deserializeAws_restJson1GetApiMappingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5204,8 +5236,7 @@ const deserializeAws_restJson1GetApisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5218,10 +5249,12 @@ const deserializeAws_restJson1GetApisCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5294,8 +5327,7 @@ const deserializeAws_restJson1GetAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5305,10 +5337,12 @@ const deserializeAws_restJson1GetAuthorizerCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5345,8 +5379,7 @@ const deserializeAws_restJson1GetAuthorizersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5359,10 +5392,12 @@ const deserializeAws_restJson1GetAuthorizersCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5415,8 +5450,7 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5426,10 +5460,12 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5466,8 +5502,7 @@ const deserializeAws_restJson1GetDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5480,10 +5515,12 @@ const deserializeAws_restJson1GetDeploymentsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5538,8 +5575,7 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5549,10 +5585,12 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5589,8 +5627,7 @@ const deserializeAws_restJson1GetDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5603,10 +5640,12 @@ const deserializeAws_restJson1GetDomainNamesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5718,8 +5757,7 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5729,10 +5767,12 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5785,8 +5825,7 @@ const deserializeAws_restJson1GetIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5796,10 +5835,12 @@ const deserializeAws_restJson1GetIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5836,8 +5877,7 @@ const deserializeAws_restJson1GetIntegrationResponsesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5850,10 +5890,12 @@ const deserializeAws_restJson1GetIntegrationResponsesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5890,8 +5932,7 @@ const deserializeAws_restJson1GetIntegrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -5904,10 +5945,12 @@ const deserializeAws_restJson1GetIntegrationsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5956,8 +5999,7 @@ const deserializeAws_restJson1GetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -5967,10 +6009,12 @@ const deserializeAws_restJson1GetModelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6007,8 +6051,7 @@ const deserializeAws_restJson1GetModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6021,10 +6064,12 @@ const deserializeAws_restJson1GetModelsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6057,8 +6102,7 @@ const deserializeAws_restJson1GetModelTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6068,10 +6112,12 @@ const deserializeAws_restJson1GetModelTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6152,8 +6198,7 @@ const deserializeAws_restJson1GetRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6163,10 +6208,12 @@ const deserializeAws_restJson1GetRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6215,8 +6262,7 @@ const deserializeAws_restJson1GetRouteResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6226,10 +6272,12 @@ const deserializeAws_restJson1GetRouteResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6266,8 +6314,7 @@ const deserializeAws_restJson1GetRouteResponsesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6280,10 +6327,12 @@ const deserializeAws_restJson1GetRouteResponsesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6320,8 +6369,7 @@ const deserializeAws_restJson1GetRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6334,10 +6382,12 @@ const deserializeAws_restJson1GetRoutesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6422,8 +6472,7 @@ const deserializeAws_restJson1GetStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6433,10 +6482,12 @@ const deserializeAws_restJson1GetStageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6473,8 +6524,7 @@ const deserializeAws_restJson1GetStagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6487,10 +6537,12 @@ const deserializeAws_restJson1GetStagesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6523,8 +6575,7 @@ const deserializeAws_restJson1GetTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6540,10 +6591,12 @@ const deserializeAws_restJson1GetTagsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6608,8 +6661,7 @@ const deserializeAws_restJson1GetVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6619,10 +6671,12 @@ const deserializeAws_restJson1GetVpcLinkCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6659,8 +6713,7 @@ const deserializeAws_restJson1GetVpcLinksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6670,10 +6723,12 @@ const deserializeAws_restJson1GetVpcLinksCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6766,8 +6821,7 @@ const deserializeAws_restJson1ImportApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6783,10 +6837,12 @@ const deserializeAws_restJson1ImportApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6879,8 +6935,7 @@ const deserializeAws_restJson1ReimportApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6896,10 +6951,12 @@ const deserializeAws_restJson1ReimportApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6928,8 +6985,7 @@ const deserializeAws_restJson1ResetAuthorizersCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFoundException": case "com.amazonaws.apigatewayv2#NotFoundException": @@ -6939,10 +6995,12 @@ const deserializeAws_restJson1ResetAuthorizersCacheCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6971,8 +7029,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -6988,10 +7045,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7020,8 +7079,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7037,10 +7095,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7133,8 +7193,7 @@ const deserializeAws_restJson1UpdateApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7150,10 +7209,12 @@ const deserializeAws_restJson1UpdateApiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7198,8 +7259,7 @@ const deserializeAws_restJson1UpdateApiMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7215,10 +7275,12 @@ const deserializeAws_restJson1UpdateApiMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7291,8 +7353,7 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7308,10 +7369,12 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7364,8 +7427,7 @@ const deserializeAws_restJson1UpdateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7381,10 +7443,12 @@ const deserializeAws_restJson1UpdateDeploymentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7439,8 +7503,7 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7456,10 +7519,12 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7571,8 +7636,7 @@ const deserializeAws_restJson1UpdateIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7588,10 +7652,12 @@ const deserializeAws_restJson1UpdateIntegrationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7644,8 +7710,7 @@ const deserializeAws_restJson1UpdateIntegrationResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7661,10 +7726,12 @@ const deserializeAws_restJson1UpdateIntegrationResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7713,8 +7780,7 @@ const deserializeAws_restJson1UpdateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7730,10 +7796,12 @@ const deserializeAws_restJson1UpdateModelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7814,8 +7882,7 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7831,10 +7898,12 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7883,8 +7952,7 @@ const deserializeAws_restJson1UpdateRouteResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -7900,10 +7968,12 @@ const deserializeAws_restJson1UpdateRouteResponseCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7988,8 +8058,7 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -8005,10 +8074,12 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8073,8 +8144,7 @@ const deserializeAws_restJson1UpdateVpcLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.apigatewayv2#BadRequestException": @@ -8087,10 +8157,12 @@ const deserializeAws_restJson1UpdateVpcLinkCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9267,7 +9339,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9293,6 +9365,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-app-mesh/src/protocols/Aws_restJson1.ts b/clients/client-app-mesh/src/protocols/Aws_restJson1.ts index 929924093ed58..a610e965e700d 100644 --- a/clients/client-app-mesh/src/protocols/Aws_restJson1.ts +++ b/clients/client-app-mesh/src/protocols/Aws_restJson1.ts @@ -1912,8 +1912,7 @@ const deserializeAws_restJson1CreateGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -1941,10 +1940,12 @@ const deserializeAws_restJson1CreateGatewayRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1975,8 +1976,7 @@ const deserializeAws_restJson1CreateMeshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2004,10 +2004,12 @@ const deserializeAws_restJson1CreateMeshCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2038,8 +2040,7 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2067,10 +2068,12 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2101,8 +2104,7 @@ const deserializeAws_restJson1CreateVirtualGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2130,10 +2132,12 @@ const deserializeAws_restJson1CreateVirtualGatewayCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2164,8 +2168,7 @@ const deserializeAws_restJson1CreateVirtualNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2193,10 +2196,12 @@ const deserializeAws_restJson1CreateVirtualNodeCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2227,8 +2232,7 @@ const deserializeAws_restJson1CreateVirtualRouterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2256,10 +2260,12 @@ const deserializeAws_restJson1CreateVirtualRouterCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2290,8 +2296,7 @@ const deserializeAws_restJson1CreateVirtualServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2319,10 +2324,12 @@ const deserializeAws_restJson1CreateVirtualServiceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2353,8 +2360,7 @@ const deserializeAws_restJson1DeleteGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2379,10 +2385,12 @@ const deserializeAws_restJson1DeleteGatewayRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2413,8 +2421,7 @@ const deserializeAws_restJson1DeleteMeshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2439,10 +2446,12 @@ const deserializeAws_restJson1DeleteMeshCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2473,8 +2482,7 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2499,10 +2507,12 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2533,8 +2543,7 @@ const deserializeAws_restJson1DeleteVirtualGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2559,10 +2568,12 @@ const deserializeAws_restJson1DeleteVirtualGatewayCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2593,8 +2604,7 @@ const deserializeAws_restJson1DeleteVirtualNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2619,10 +2629,12 @@ const deserializeAws_restJson1DeleteVirtualNodeCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2653,8 +2665,7 @@ const deserializeAws_restJson1DeleteVirtualRouterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2679,10 +2690,12 @@ const deserializeAws_restJson1DeleteVirtualRouterCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2713,8 +2726,7 @@ const deserializeAws_restJson1DeleteVirtualServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2739,10 +2751,12 @@ const deserializeAws_restJson1DeleteVirtualServiceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2773,8 +2787,7 @@ const deserializeAws_restJson1DescribeGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2796,10 +2809,12 @@ const deserializeAws_restJson1DescribeGatewayRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2830,8 +2845,7 @@ const deserializeAws_restJson1DescribeMeshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2853,10 +2867,12 @@ const deserializeAws_restJson1DescribeMeshCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2887,8 +2903,7 @@ const deserializeAws_restJson1DescribeRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2910,10 +2925,12 @@ const deserializeAws_restJson1DescribeRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2944,8 +2961,7 @@ const deserializeAws_restJson1DescribeVirtualGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -2967,10 +2983,12 @@ const deserializeAws_restJson1DescribeVirtualGatewayCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3001,8 +3019,7 @@ const deserializeAws_restJson1DescribeVirtualNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3024,10 +3041,12 @@ const deserializeAws_restJson1DescribeVirtualNodeCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3058,8 +3077,7 @@ const deserializeAws_restJson1DescribeVirtualRouterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3081,10 +3099,12 @@ const deserializeAws_restJson1DescribeVirtualRouterCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3115,8 +3135,7 @@ const deserializeAws_restJson1DescribeVirtualServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3138,10 +3157,12 @@ const deserializeAws_restJson1DescribeVirtualServiceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3178,8 +3199,7 @@ const deserializeAws_restJson1ListGatewayRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3201,10 +3221,12 @@ const deserializeAws_restJson1ListGatewayRoutesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3241,8 +3263,7 @@ const deserializeAws_restJson1ListMeshesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3264,10 +3285,12 @@ const deserializeAws_restJson1ListMeshesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3304,8 +3327,7 @@ const deserializeAws_restJson1ListRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3327,10 +3349,12 @@ const deserializeAws_restJson1ListRoutesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3367,8 +3391,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3390,10 +3413,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3430,8 +3455,7 @@ const deserializeAws_restJson1ListVirtualGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3453,10 +3477,12 @@ const deserializeAws_restJson1ListVirtualGatewaysCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3493,8 +3519,7 @@ const deserializeAws_restJson1ListVirtualNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3516,10 +3541,12 @@ const deserializeAws_restJson1ListVirtualNodesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3556,8 +3583,7 @@ const deserializeAws_restJson1ListVirtualRoutersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3579,10 +3605,12 @@ const deserializeAws_restJson1ListVirtualRoutersCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3619,8 +3647,7 @@ const deserializeAws_restJson1ListVirtualServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3642,10 +3669,12 @@ const deserializeAws_restJson1ListVirtualServicesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3674,8 +3703,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3700,10 +3728,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3732,8 +3762,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3755,10 +3784,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3789,8 +3820,7 @@ const deserializeAws_restJson1UpdateGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3818,10 +3848,12 @@ const deserializeAws_restJson1UpdateGatewayRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3852,8 +3884,7 @@ const deserializeAws_restJson1UpdateMeshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3878,10 +3909,12 @@ const deserializeAws_restJson1UpdateMeshCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3912,8 +3945,7 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -3941,10 +3973,12 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3975,8 +4009,7 @@ const deserializeAws_restJson1UpdateVirtualGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -4004,10 +4037,12 @@ const deserializeAws_restJson1UpdateVirtualGatewayCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4038,8 +4073,7 @@ const deserializeAws_restJson1UpdateVirtualNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -4067,10 +4101,12 @@ const deserializeAws_restJson1UpdateVirtualNodeCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4101,8 +4137,7 @@ const deserializeAws_restJson1UpdateVirtualRouterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -4130,10 +4165,12 @@ const deserializeAws_restJson1UpdateVirtualRouterCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4164,8 +4201,7 @@ const deserializeAws_restJson1UpdateVirtualServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appmesh#BadRequestException": @@ -4193,10 +4229,12 @@ const deserializeAws_restJson1UpdateVirtualServiceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8128,7 +8166,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8154,6 +8192,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appconfig/src/protocols/Aws_restJson1.ts b/clients/client-appconfig/src/protocols/Aws_restJson1.ts index b69acab911799..e4e6b87e2823c 100644 --- a/clients/client-appconfig/src/protocols/Aws_restJson1.ts +++ b/clients/client-appconfig/src/protocols/Aws_restJson1.ts @@ -1436,8 +1436,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1447,10 +1446,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1511,8 +1512,7 @@ const deserializeAws_restJson1CreateConfigurationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1525,10 +1525,12 @@ const deserializeAws_restJson1CreateConfigurationProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1589,8 +1591,7 @@ const deserializeAws_restJson1CreateDeploymentStrategyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1600,10 +1601,12 @@ const deserializeAws_restJson1CreateDeploymentStrategyCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1656,8 +1659,7 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1670,10 +1672,12 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1724,8 +1728,7 @@ const deserializeAws_restJson1CreateHostedConfigurationVersionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1747,10 +1750,12 @@ const deserializeAws_restJson1CreateHostedConfigurationVersionCommandError = asy throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1779,8 +1784,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1793,10 +1797,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1825,8 +1831,7 @@ const deserializeAws_restJson1DeleteConfigurationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1842,10 +1847,12 @@ const deserializeAws_restJson1DeleteConfigurationProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1874,8 +1881,7 @@ const deserializeAws_restJson1DeleteDeploymentStrategyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1888,10 +1894,12 @@ const deserializeAws_restJson1DeleteDeploymentStrategyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1920,8 +1928,7 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1937,10 +1944,12 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1969,8 +1978,7 @@ const deserializeAws_restJson1DeleteHostedConfigurationVersionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -1983,10 +1991,12 @@ const deserializeAws_restJson1DeleteHostedConfigurationVersionCommandError = asy throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2027,8 +2037,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2041,10 +2050,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2083,8 +2094,7 @@ const deserializeAws_restJson1GetConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2097,10 +2107,12 @@ const deserializeAws_restJson1GetConfigurationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2161,8 +2173,7 @@ const deserializeAws_restJson1GetConfigurationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2175,10 +2186,12 @@ const deserializeAws_restJson1GetConfigurationProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2279,8 +2292,7 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2293,10 +2305,12 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2357,8 +2371,7 @@ const deserializeAws_restJson1GetDeploymentStrategyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2371,10 +2384,12 @@ const deserializeAws_restJson1GetDeploymentStrategyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2427,8 +2442,7 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2441,10 +2455,12 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2495,8 +2511,7 @@ const deserializeAws_restJson1GetHostedConfigurationVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2509,10 +2524,12 @@ const deserializeAws_restJson1GetHostedConfigurationVersionCommandError = async throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2549,8 +2566,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2560,10 +2576,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2600,8 +2618,7 @@ const deserializeAws_restJson1ListConfigurationProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2614,10 +2631,12 @@ const deserializeAws_restJson1ListConfigurationProfilesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2654,8 +2673,7 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2668,10 +2686,12 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2708,8 +2728,7 @@ const deserializeAws_restJson1ListDeploymentStrategiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2719,10 +2738,12 @@ const deserializeAws_restJson1ListDeploymentStrategiesCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2759,8 +2780,7 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2773,10 +2793,12 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2813,8 +2835,7 @@ const deserializeAws_restJson1ListHostedConfigurationVersionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2827,10 +2848,12 @@ const deserializeAws_restJson1ListHostedConfigurationVersionsCommandError = asyn throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2863,8 +2886,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2877,10 +2899,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2981,8 +3005,7 @@ const deserializeAws_restJson1StartDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -2998,10 +3021,12 @@ const deserializeAws_restJson1StartDeploymentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3102,8 +3127,7 @@ const deserializeAws_restJson1StopDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3116,10 +3140,12 @@ const deserializeAws_restJson1StopDeploymentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3148,8 +3174,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3162,10 +3187,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3194,8 +3221,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3208,10 +3234,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3252,8 +3280,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3266,10 +3293,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3330,8 +3359,7 @@ const deserializeAws_restJson1UpdateConfigurationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3344,10 +3372,12 @@ const deserializeAws_restJson1UpdateConfigurationProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3408,8 +3438,7 @@ const deserializeAws_restJson1UpdateDeploymentStrategyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3422,10 +3451,12 @@ const deserializeAws_restJson1UpdateDeploymentStrategyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3478,8 +3509,7 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3492,10 +3522,12 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3524,8 +3556,7 @@ const deserializeAws_restJson1ValidateConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfig#BadRequestException": @@ -3538,10 +3569,12 @@ const deserializeAws_restJson1ValidateConfigurationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4039,7 +4072,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4065,6 +4098,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appconfigdata/src/protocols/Aws_restJson1.ts b/clients/client-appconfigdata/src/protocols/Aws_restJson1.ts index 339b9abb570be..ded3805e59082 100644 --- a/clients/client-appconfigdata/src/protocols/Aws_restJson1.ts +++ b/clients/client-appconfigdata/src/protocols/Aws_restJson1.ts @@ -128,8 +128,7 @@ const deserializeAws_restJson1GetLatestConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfigdata#BadRequestException": @@ -145,10 +144,12 @@ const deserializeAws_restJson1GetLatestConfigurationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -181,8 +182,7 @@ const deserializeAws_restJson1StartConfigurationSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appconfigdata#BadRequestException": @@ -198,10 +198,12 @@ const deserializeAws_restJson1StartConfigurationSessionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -365,7 +367,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -391,6 +393,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appflow/src/protocols/Aws_restJson1.ts b/clients/client-appflow/src/protocols/Aws_restJson1.ts index 1067d2b1926e7..3560c615ae06a 100644 --- a/clients/client-appflow/src/protocols/Aws_restJson1.ts +++ b/clients/client-appflow/src/protocols/Aws_restJson1.ts @@ -912,8 +912,7 @@ const deserializeAws_restJson1CreateConnectorProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -932,10 +931,12 @@ const deserializeAws_restJson1CreateConnectorProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -972,8 +973,7 @@ const deserializeAws_restJson1CreateFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -998,10 +998,12 @@ const deserializeAws_restJson1CreateFlowCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1030,8 +1032,7 @@ const deserializeAws_restJson1DeleteConnectorProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -1044,10 +1045,12 @@ const deserializeAws_restJson1DeleteConnectorProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1076,8 +1079,7 @@ const deserializeAws_restJson1DeleteFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -1090,10 +1092,12 @@ const deserializeAws_restJson1DeleteFlowCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1129,8 +1133,7 @@ const deserializeAws_restJson1DescribeConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1143,10 +1146,12 @@ const deserializeAws_restJson1DescribeConnectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1187,7 @@ const deserializeAws_restJson1DescribeConnectorEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConnectorAuthenticationException": case "com.amazonaws.appflow#ConnectorAuthenticationException": @@ -1202,10 +1206,12 @@ const deserializeAws_restJson1DescribeConnectorEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1245,8 +1251,7 @@ const deserializeAws_restJson1DescribeConnectorProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1256,10 +1261,12 @@ const deserializeAws_restJson1DescribeConnectorProfilesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1303,8 +1310,7 @@ const deserializeAws_restJson1DescribeConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1314,10 +1320,12 @@ const deserializeAws_restJson1DescribeConnectorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1413,8 +1421,7 @@ const deserializeAws_restJson1DescribeFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1424,10 +1431,12 @@ const deserializeAws_restJson1DescribeFlowCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1464,8 +1473,7 @@ const deserializeAws_restJson1DescribeFlowExecutionRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1478,10 +1486,12 @@ const deserializeAws_restJson1DescribeFlowExecutionRecordsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1514,8 +1524,7 @@ const deserializeAws_restJson1ListConnectorEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConnectorAuthenticationException": case "com.amazonaws.appflow#ConnectorAuthenticationException": @@ -1534,10 +1543,12 @@ const deserializeAws_restJson1ListConnectorEntitiesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1574,8 +1585,7 @@ const deserializeAws_restJson1ListConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1585,10 +1595,12 @@ const deserializeAws_restJson1ListConnectorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1625,8 +1637,7 @@ const deserializeAws_restJson1ListFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1636,10 +1647,12 @@ const deserializeAws_restJson1ListFlowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1672,8 +1685,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1686,10 +1698,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1722,8 +1736,7 @@ const deserializeAws_restJson1RegisterConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appflow#AccessDeniedException": @@ -1754,10 +1767,12 @@ const deserializeAws_restJson1RegisterConnectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1798,8 +1813,7 @@ const deserializeAws_restJson1StartFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -1815,10 +1829,12 @@ const deserializeAws_restJson1StartFlowCommandError = async ( throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1855,8 +1871,7 @@ const deserializeAws_restJson1StopFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -1872,10 +1887,12 @@ const deserializeAws_restJson1StopFlowCommandError = async ( throw await deserializeAws_restJson1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1904,8 +1921,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -1918,10 +1934,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1950,8 +1968,7 @@ const deserializeAws_restJson1UnregisterConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -1964,10 +1981,12 @@ const deserializeAws_restJson1UnregisterConnectorCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1996,8 +2015,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.appflow#InternalServerException": @@ -2010,10 +2028,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2046,8 +2066,7 @@ const deserializeAws_restJson1UpdateConnectorProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -2066,10 +2085,12 @@ const deserializeAws_restJson1UpdateConnectorProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2102,8 +2123,7 @@ const deserializeAws_restJson1UpdateFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.appflow#ConflictException": @@ -2128,10 +2148,12 @@ const deserializeAws_restJson1UpdateFlowCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5936,7 +5958,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5962,6 +5984,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appintegrations/src/protocols/Aws_restJson1.ts b/clients/client-appintegrations/src/protocols/Aws_restJson1.ts index c8230cb6dae48..e5ef41cc8a66f 100644 --- a/clients/client-appintegrations/src/protocols/Aws_restJson1.ts +++ b/clients/client-appintegrations/src/protocols/Aws_restJson1.ts @@ -602,8 +602,7 @@ const deserializeAws_restJson1CreateDataIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -625,10 +624,12 @@ const deserializeAws_restJson1CreateDataIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -661,8 +662,7 @@ const deserializeAws_restJson1CreateEventIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -684,10 +684,12 @@ const deserializeAws_restJson1CreateEventIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -716,8 +718,7 @@ const deserializeAws_restJson1DeleteDataIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -736,10 +737,12 @@ const deserializeAws_restJson1DeleteDataIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -768,8 +771,7 @@ const deserializeAws_restJson1DeleteEventIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -788,10 +790,12 @@ const deserializeAws_restJson1DeleteEventIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -852,8 +856,7 @@ const deserializeAws_restJson1GetDataIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -872,10 +875,12 @@ const deserializeAws_restJson1GetDataIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -928,8 +933,7 @@ const deserializeAws_restJson1GetEventIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -948,10 +952,12 @@ const deserializeAws_restJson1GetEventIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -991,8 +997,7 @@ const deserializeAws_restJson1ListDataIntegrationAssociationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1011,10 +1016,12 @@ const deserializeAws_restJson1ListDataIntegrationAssociationsCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1051,8 +1058,7 @@ const deserializeAws_restJson1ListDataIntegrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1068,10 +1074,12 @@ const deserializeAws_restJson1ListDataIntegrationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1111,8 +1119,7 @@ const deserializeAws_restJson1ListEventIntegrationAssociationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1131,10 +1138,12 @@ const deserializeAws_restJson1ListEventIntegrationAssociationsCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1171,8 +1180,7 @@ const deserializeAws_restJson1ListEventIntegrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1188,10 +1196,12 @@ const deserializeAws_restJson1ListEventIntegrationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1224,8 +1234,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.appintegrations#InternalServiceError": @@ -1241,10 +1250,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1273,8 +1284,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.appintegrations#InternalServiceError": @@ -1290,10 +1300,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1334,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.appintegrations#InternalServiceError": @@ -1339,10 +1350,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1371,8 +1384,7 @@ const deserializeAws_restJson1UpdateDataIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1391,10 +1403,12 @@ const deserializeAws_restJson1UpdateDataIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1423,8 +1437,7 @@ const deserializeAws_restJson1UpdateEventIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appintegrations#AccessDeniedException": @@ -1443,10 +1456,12 @@ const deserializeAws_restJson1UpdateEventIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1783,7 +1798,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1809,6 +1824,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-application-auto-scaling/src/protocols/Aws_json1_1.ts b/clients/client-application-auto-scaling/src/protocols/Aws_json1_1.ts index 15b45d4bc4038..08bc609c91eb5 100644 --- a/clients/client-application-auto-scaling/src/protocols/Aws_json1_1.ts +++ b/clients/client-application-auto-scaling/src/protocols/Aws_json1_1.ts @@ -252,8 +252,7 @@ const deserializeAws_json1_1DeleteScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -269,10 +268,12 @@ const deserializeAws_json1_1DeleteScalingPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -304,8 +305,7 @@ const deserializeAws_json1_1DeleteScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -321,10 +321,12 @@ const deserializeAws_json1_1DeleteScheduledActionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -356,8 +358,7 @@ const deserializeAws_json1_1DeregisterScalableTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -373,10 +374,12 @@ const deserializeAws_json1_1DeregisterScalableTargetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -408,8 +411,7 @@ const deserializeAws_json1_1DescribeScalableTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -425,10 +427,12 @@ const deserializeAws_json1_1DescribeScalableTargetsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -460,8 +464,7 @@ const deserializeAws_json1_1DescribeScalingActivitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -477,10 +480,12 @@ const deserializeAws_json1_1DescribeScalingActivitiesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -512,8 +517,7 @@ const deserializeAws_json1_1DescribeScalingPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -532,10 +536,12 @@ const deserializeAws_json1_1DescribeScalingPoliciesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -567,8 +573,7 @@ const deserializeAws_json1_1DescribeScheduledActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -584,10 +589,12 @@ const deserializeAws_json1_1DescribeScheduledActionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -619,8 +626,7 @@ const deserializeAws_json1_1PutScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -642,10 +648,12 @@ const deserializeAws_json1_1PutScalingPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -677,8 +685,7 @@ const deserializeAws_json1_1PutScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -697,10 +704,12 @@ const deserializeAws_json1_1PutScheduledActionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -732,8 +741,7 @@ const deserializeAws_json1_1RegisterScalableTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.applicationautoscaling#ConcurrentUpdateException": @@ -749,10 +757,12 @@ const deserializeAws_json1_1RegisterScalableTargetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1675,7 +1685,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1701,6 +1711,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-application-discovery-service/src/protocols/Aws_json1_1.ts b/clients/client-application-discovery-service/src/protocols/Aws_json1_1.ts index 1444e3c4ed98d..e1a613f52e23e 100644 --- a/clients/client-application-discovery-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-application-discovery-service/src/protocols/Aws_json1_1.ts @@ -519,8 +519,7 @@ const deserializeAws_json1_1AssociateConfigurationItemsToApplicationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -539,10 +538,12 @@ const deserializeAws_json1_1AssociateConfigurationItemsToApplicationCommandError throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -574,8 +575,7 @@ const deserializeAws_json1_1BatchDeleteImportDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -594,10 +594,12 @@ const deserializeAws_json1_1BatchDeleteImportDataCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -629,8 +631,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -649,10 +650,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -684,8 +687,7 @@ const deserializeAws_json1_1CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -707,10 +709,12 @@ const deserializeAws_json1_1CreateTagsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -742,8 +746,7 @@ const deserializeAws_json1_1DeleteApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -762,10 +765,12 @@ const deserializeAws_json1_1DeleteApplicationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -797,8 +802,7 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -820,10 +824,12 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -855,8 +861,7 @@ const deserializeAws_json1_1DescribeAgentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -875,10 +880,12 @@ const deserializeAws_json1_1DescribeAgentsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -910,8 +917,7 @@ const deserializeAws_json1_1DescribeConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -930,10 +936,12 @@ const deserializeAws_json1_1DescribeConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -965,8 +973,7 @@ const deserializeAws_json1_1DescribeContinuousExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -991,10 +998,12 @@ const deserializeAws_json1_1DescribeContinuousExportsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1026,8 +1035,7 @@ const deserializeAws_json1_1DescribeExportConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1049,10 +1057,12 @@ const deserializeAws_json1_1DescribeExportConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1084,8 +1094,7 @@ const deserializeAws_json1_1DescribeExportTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1104,10 +1113,12 @@ const deserializeAws_json1_1DescribeExportTasksCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1139,8 +1150,7 @@ const deserializeAws_json1_1DescribeImportTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1159,10 +1169,12 @@ const deserializeAws_json1_1DescribeImportTasksCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1194,8 +1206,7 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1217,10 +1228,12 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1252,8 +1265,7 @@ const deserializeAws_json1_1DisassociateConfigurationItemsFromApplicationCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1272,10 +1284,12 @@ const deserializeAws_json1_1DisassociateConfigurationItemsFromApplicationCommand throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1307,8 +1321,7 @@ const deserializeAws_json1_1ExportConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1330,10 +1343,12 @@ const deserializeAws_json1_1ExportConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1365,8 +1380,7 @@ const deserializeAws_json1_1GetDiscoverySummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1385,10 +1399,12 @@ const deserializeAws_json1_1GetDiscoverySummaryCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1420,8 +1436,7 @@ const deserializeAws_json1_1ListConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1443,10 +1458,12 @@ const deserializeAws_json1_1ListConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1495,7 @@ const deserializeAws_json1_1ListServerNeighborsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1498,10 +1514,12 @@ const deserializeAws_json1_1ListServerNeighborsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1533,8 +1551,7 @@ const deserializeAws_json1_1StartContinuousExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1562,10 +1579,12 @@ const deserializeAws_json1_1StartContinuousExportCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1597,8 +1616,7 @@ const deserializeAws_json1_1StartDataCollectionByAgentIdsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1617,10 +1635,12 @@ const deserializeAws_json1_1StartDataCollectionByAgentIdsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1652,8 +1672,7 @@ const deserializeAws_json1_1StartExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1675,10 +1694,12 @@ const deserializeAws_json1_1StartExportTaskCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1710,8 +1731,7 @@ const deserializeAws_json1_1StartImportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1733,10 +1753,12 @@ const deserializeAws_json1_1StartImportTaskCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1790,7 @@ const deserializeAws_json1_1StopContinuousExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1797,10 +1818,12 @@ const deserializeAws_json1_1StopContinuousExportCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1832,8 +1855,7 @@ const deserializeAws_json1_1StopDataCollectionByAgentIdsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1852,10 +1874,12 @@ const deserializeAws_json1_1StopDataCollectionByAgentIdsCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1887,8 +1911,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.applicationdiscoveryservice#AuthorizationErrorException": @@ -1907,10 +1930,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1ServerInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3305,7 +3330,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3331,6 +3356,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-application-insights/src/protocols/Aws_json1_1.ts b/clients/client-application-insights/src/protocols/Aws_json1_1.ts index 9452504cb7a2f..040c1ebb01441 100644 --- a/clients/client-application-insights/src/protocols/Aws_json1_1.ts +++ b/clients/client-application-insights/src/protocols/Aws_json1_1.ts @@ -523,8 +523,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationinsights#AccessDeniedException": @@ -546,10 +545,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -581,8 +582,7 @@ const deserializeAws_json1_1CreateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -598,10 +598,12 @@ const deserializeAws_json1_1CreateComponentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -633,8 +635,7 @@ const deserializeAws_json1_1CreateLogPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -650,10 +651,12 @@ const deserializeAws_json1_1CreateLogPatternCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -685,8 +688,7 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.applicationinsights#BadRequestException": @@ -702,10 +704,12 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -737,8 +741,7 @@ const deserializeAws_json1_1DeleteComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -751,10 +754,12 @@ const deserializeAws_json1_1DeleteComponentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -786,8 +791,7 @@ const deserializeAws_json1_1DeleteLogPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.applicationinsights#BadRequestException": @@ -803,10 +807,12 @@ const deserializeAws_json1_1DeleteLogPatternCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -838,8 +844,7 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -852,10 +857,12 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -887,8 +894,7 @@ const deserializeAws_json1_1DescribeComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -901,10 +907,12 @@ const deserializeAws_json1_1DescribeComponentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -936,8 +944,7 @@ const deserializeAws_json1_1DescribeComponentConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -950,10 +957,12 @@ const deserializeAws_json1_1DescribeComponentConfigurationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -985,8 +994,7 @@ const deserializeAws_json1_1DescribeComponentConfigurationRecommendationCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -999,10 +1007,12 @@ const deserializeAws_json1_1DescribeComponentConfigurationRecommendationCommandE throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1034,8 +1044,7 @@ const deserializeAws_json1_1DescribeLogPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1048,10 +1057,12 @@ const deserializeAws_json1_1DescribeLogPatternCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1083,8 +1094,7 @@ const deserializeAws_json1_1DescribeObservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1097,10 +1107,12 @@ const deserializeAws_json1_1DescribeObservationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1132,8 +1144,7 @@ const deserializeAws_json1_1DescribeProblemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1146,10 +1157,12 @@ const deserializeAws_json1_1DescribeProblemCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1181,8 +1194,7 @@ const deserializeAws_json1_1DescribeProblemObservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1195,10 +1207,12 @@ const deserializeAws_json1_1DescribeProblemObservationsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1230,8 +1244,7 @@ const deserializeAws_json1_1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1241,10 +1254,12 @@ const deserializeAws_json1_1ListApplicationsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1276,8 +1291,7 @@ const deserializeAws_json1_1ListComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1290,10 +1304,12 @@ const deserializeAws_json1_1ListComponentsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1325,8 +1341,7 @@ const deserializeAws_json1_1ListConfigurationHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1339,10 +1354,12 @@ const deserializeAws_json1_1ListConfigurationHistoryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1374,8 +1391,7 @@ const deserializeAws_json1_1ListLogPatternsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1388,10 +1404,12 @@ const deserializeAws_json1_1ListLogPatternsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1423,8 +1441,7 @@ const deserializeAws_json1_1ListLogPatternSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1437,10 +1454,12 @@ const deserializeAws_json1_1ListLogPatternSetsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1472,8 +1491,7 @@ const deserializeAws_json1_1ListProblemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1486,10 +1504,12 @@ const deserializeAws_json1_1ListProblemsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1541,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.applicationinsights#ResourceNotFoundException": @@ -1532,10 +1551,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1567,8 +1588,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.applicationinsights#ResourceNotFoundException": @@ -1581,10 +1601,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1616,8 +1638,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.applicationinsights#ResourceNotFoundException": @@ -1627,10 +1648,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1662,8 +1685,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1676,10 +1698,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1711,8 +1735,7 @@ const deserializeAws_json1_1UpdateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1728,10 +1751,12 @@ const deserializeAws_json1_1UpdateComponentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1763,8 +1788,7 @@ const deserializeAws_json1_1UpdateComponentConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1777,10 +1801,12 @@ const deserializeAws_json1_1UpdateComponentConfigurationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1812,8 +1838,7 @@ const deserializeAws_json1_1UpdateLogPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.applicationinsights#InternalServerException": @@ -1829,10 +1854,12 @@ const deserializeAws_json1_1UpdateLogPatternCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3000,7 +3027,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3026,6 +3053,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-applicationcostprofiler/src/protocols/Aws_restJson1.ts b/clients/client-applicationcostprofiler/src/protocols/Aws_restJson1.ts index f7a0f67a745f7..9871af9474050 100644 --- a/clients/client-applicationcostprofiler/src/protocols/Aws_restJson1.ts +++ b/clients/client-applicationcostprofiler/src/protocols/Aws_restJson1.ts @@ -263,8 +263,7 @@ const deserializeAws_restJson1DeleteReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -280,10 +279,12 @@ const deserializeAws_restJson1DeleteReportDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -340,8 +341,7 @@ const deserializeAws_restJson1GetReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -357,10 +357,12 @@ const deserializeAws_restJson1GetReportDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -393,8 +395,7 @@ const deserializeAws_restJson1ImportApplicationUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -410,10 +411,12 @@ const deserializeAws_restJson1ImportApplicationUsageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -450,8 +453,7 @@ const deserializeAws_restJson1ListReportDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -467,10 +469,12 @@ const deserializeAws_restJson1ListReportDefinitionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -503,8 +507,7 @@ const deserializeAws_restJson1PutReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -523,10 +526,12 @@ const deserializeAws_restJson1PutReportDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -559,8 +564,7 @@ const deserializeAws_restJson1UpdateReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.applicationcostprofiler#AccessDeniedException": @@ -576,10 +580,12 @@ const deserializeAws_restJson1UpdateReportDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -757,7 +763,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -783,6 +789,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-apprunner/src/protocols/Aws_json1_0.ts b/clients/client-apprunner/src/protocols/Aws_json1_0.ts index 1a666875cc394..327602f312168 100644 --- a/clients/client-apprunner/src/protocols/Aws_json1_0.ts +++ b/clients/client-apprunner/src/protocols/Aws_json1_0.ts @@ -598,8 +598,7 @@ const deserializeAws_json1_0AssociateCustomDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -612,10 +611,12 @@ const deserializeAws_json1_0AssociateCustomDomainCommandError = async ( throw await deserializeAws_json1_0InvalidStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -647,8 +648,7 @@ const deserializeAws_json1_0CreateAutoScalingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -661,10 +661,12 @@ const deserializeAws_json1_0CreateAutoScalingConfigurationCommandError = async ( throw await deserializeAws_json1_0ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -696,8 +698,7 @@ const deserializeAws_json1_0CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -710,10 +711,12 @@ const deserializeAws_json1_0CreateConnectionCommandError = async ( throw await deserializeAws_json1_0ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -745,8 +748,7 @@ const deserializeAws_json1_0CreateObservabilityConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -759,10 +761,12 @@ const deserializeAws_json1_0CreateObservabilityConfigurationCommandError = async throw await deserializeAws_json1_0ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -794,8 +798,7 @@ const deserializeAws_json1_0CreateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -808,10 +811,12 @@ const deserializeAws_json1_0CreateServiceCommandError = async ( throw await deserializeAws_json1_0ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -843,8 +848,7 @@ const deserializeAws_json1_0CreateVpcConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -857,10 +861,12 @@ const deserializeAws_json1_0CreateVpcConnectorCommandError = async ( throw await deserializeAws_json1_0ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -892,8 +898,7 @@ const deserializeAws_json1_0DeleteAutoScalingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -906,10 +911,12 @@ const deserializeAws_json1_0DeleteAutoScalingConfigurationCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -941,8 +948,7 @@ const deserializeAws_json1_0DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -955,10 +961,12 @@ const deserializeAws_json1_0DeleteConnectionCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -990,8 +998,7 @@ const deserializeAws_json1_0DeleteObservabilityConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1004,10 +1011,12 @@ const deserializeAws_json1_0DeleteObservabilityConfigurationCommandError = async throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1039,8 +1048,7 @@ const deserializeAws_json1_0DeleteServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1056,10 +1064,12 @@ const deserializeAws_json1_0DeleteServiceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1091,8 +1101,7 @@ const deserializeAws_json1_0DeleteVpcConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1105,10 +1114,12 @@ const deserializeAws_json1_0DeleteVpcConnectorCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1140,8 +1151,7 @@ const deserializeAws_json1_0DescribeAutoScalingConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1154,10 +1164,12 @@ const deserializeAws_json1_0DescribeAutoScalingConfigurationCommandError = async throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1189,8 +1201,7 @@ const deserializeAws_json1_0DescribeCustomDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1203,10 +1214,12 @@ const deserializeAws_json1_0DescribeCustomDomainsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1238,8 +1251,7 @@ const deserializeAws_json1_0DescribeObservabilityConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1252,10 +1264,12 @@ const deserializeAws_json1_0DescribeObservabilityConfigurationCommandError = asy throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1287,8 +1301,7 @@ const deserializeAws_json1_0DescribeServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1301,10 +1314,12 @@ const deserializeAws_json1_0DescribeServiceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1336,8 +1351,7 @@ const deserializeAws_json1_0DescribeVpcConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1350,10 +1364,12 @@ const deserializeAws_json1_0DescribeVpcConnectorCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1385,8 +1401,7 @@ const deserializeAws_json1_0DisassociateCustomDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1402,10 +1417,12 @@ const deserializeAws_json1_0DisassociateCustomDomainCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1437,8 +1454,7 @@ const deserializeAws_json1_0ListAutoScalingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1448,10 +1464,12 @@ const deserializeAws_json1_0ListAutoScalingConfigurationsCommandError = async ( throw await deserializeAws_json1_0InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1483,8 +1501,7 @@ const deserializeAws_json1_0ListConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1494,10 +1511,12 @@ const deserializeAws_json1_0ListConnectionsCommandError = async ( throw await deserializeAws_json1_0InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1529,8 +1548,7 @@ const deserializeAws_json1_0ListObservabilityConfigurationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1540,10 +1558,12 @@ const deserializeAws_json1_0ListObservabilityConfigurationsCommandError = async throw await deserializeAws_json1_0InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1575,8 +1595,7 @@ const deserializeAws_json1_0ListOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1589,10 +1608,12 @@ const deserializeAws_json1_0ListOperationsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1624,8 +1645,7 @@ const deserializeAws_json1_0ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1635,10 +1655,12 @@ const deserializeAws_json1_0ListServicesCommandError = async ( throw await deserializeAws_json1_0InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1670,8 +1692,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1687,10 +1708,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1722,8 +1745,7 @@ const deserializeAws_json1_0ListVpcConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1733,10 +1755,12 @@ const deserializeAws_json1_0ListVpcConnectorsCommandError = async ( throw await deserializeAws_json1_0InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1792,7 @@ const deserializeAws_json1_0PauseServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1785,10 +1808,12 @@ const deserializeAws_json1_0PauseServiceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1820,8 +1845,7 @@ const deserializeAws_json1_0ResumeServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1837,10 +1861,12 @@ const deserializeAws_json1_0ResumeServiceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1872,8 +1898,7 @@ const deserializeAws_json1_0StartDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1886,10 +1911,12 @@ const deserializeAws_json1_0StartDeploymentCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1921,8 +1948,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1938,10 +1964,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1973,8 +2001,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -1990,10 +2017,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2025,8 +2054,7 @@ const deserializeAws_json1_0UpdateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.apprunner#InternalServiceErrorException": @@ -2042,10 +2070,12 @@ const deserializeAws_json1_0UpdateServiceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3679,7 +3709,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3705,6 +3735,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appstream/src/protocols/Aws_json1_1.ts b/clients/client-appstream/src/protocols/Aws_json1_1.ts index ebe156bd20877..5b551c8b68ccd 100644 --- a/clients/client-appstream/src/protocols/Aws_json1_1.ts +++ b/clients/client-appstream/src/protocols/Aws_json1_1.ts @@ -1219,8 +1219,7 @@ const deserializeAws_json1_1AssociateApplicationFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1239,10 +1238,12 @@ const deserializeAws_json1_1AssociateApplicationFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1274,8 +1275,7 @@ const deserializeAws_json1_1AssociateApplicationToEntitlementCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntitlementNotFoundException": case "com.amazonaws.appstream#EntitlementNotFoundException": @@ -1291,10 +1291,12 @@ const deserializeAws_json1_1AssociateApplicationToEntitlementCommandError = asyn throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1326,8 +1328,7 @@ const deserializeAws_json1_1AssociateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1349,10 +1350,12 @@ const deserializeAws_json1_1AssociateFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1384,8 +1387,7 @@ const deserializeAws_json1_1BatchAssociateUserStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -1395,10 +1397,12 @@ const deserializeAws_json1_1BatchAssociateUserStackCommandError = async ( throw await deserializeAws_json1_1OperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1430,8 +1434,7 @@ const deserializeAws_json1_1BatchDisassociateUserStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -1441,10 +1444,12 @@ const deserializeAws_json1_1BatchDisassociateUserStackCommandError = async ( throw await deserializeAws_json1_1OperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1476,8 +1481,7 @@ const deserializeAws_json1_1CopyImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IncompatibleImageException": case "com.amazonaws.appstream#IncompatibleImageException": @@ -1499,10 +1503,12 @@ const deserializeAws_json1_1CopyImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1534,8 +1540,7 @@ const deserializeAws_json1_1CreateAppBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1551,10 +1556,12 @@ const deserializeAws_json1_1CreateAppBlockCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1586,8 +1593,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1606,10 +1612,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1641,8 +1649,7 @@ const deserializeAws_json1_1CreateDirectoryConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -1664,10 +1671,12 @@ const deserializeAws_json1_1CreateDirectoryConfigCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1699,8 +1708,7 @@ const deserializeAws_json1_1CreateEntitlementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntitlementAlreadyExistsException": case "com.amazonaws.appstream#EntitlementAlreadyExistsException": @@ -1716,10 +1724,12 @@ const deserializeAws_json1_1CreateEntitlementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1751,8 +1761,7 @@ const deserializeAws_json1_1CreateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1789,10 +1798,12 @@ const deserializeAws_json1_1CreateFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1824,8 +1835,7 @@ const deserializeAws_json1_1CreateImageBuilderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1862,10 +1872,12 @@ const deserializeAws_json1_1CreateImageBuilderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1897,8 +1909,7 @@ const deserializeAws_json1_1CreateImageBuilderStreamingURLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.appstream#OperationNotPermittedException": @@ -1908,10 +1919,12 @@ const deserializeAws_json1_1CreateImageBuilderStreamingURLCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1956,7 @@ const deserializeAws_json1_1CreateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -1969,10 +1981,12 @@ const deserializeAws_json1_1CreateStackCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2004,8 +2018,7 @@ const deserializeAws_json1_1CreateStreamingURLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -2021,10 +2034,12 @@ const deserializeAws_json1_1CreateStreamingURLCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2056,8 +2071,7 @@ const deserializeAws_json1_1CreateUpdatedImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2082,10 +2096,12 @@ const deserializeAws_json1_1CreateUpdatedImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2117,8 +2133,7 @@ const deserializeAws_json1_1CreateUsageReportSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -2131,10 +2146,12 @@ const deserializeAws_json1_1CreateUsageReportSubscriptionCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2166,8 +2183,7 @@ const deserializeAws_json1_1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -2186,10 +2202,12 @@ const deserializeAws_json1_1CreateUserCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2221,8 +2239,7 @@ const deserializeAws_json1_1DeleteAppBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2235,10 +2252,12 @@ const deserializeAws_json1_1DeleteAppBlockCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2270,8 +2289,7 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2287,10 +2305,12 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2322,8 +2342,7 @@ const deserializeAws_json1_1DeleteDirectoryConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.appstream#ResourceInUseException": @@ -2333,10 +2352,12 @@ const deserializeAws_json1_1DeleteDirectoryConfigCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2368,8 +2389,7 @@ const deserializeAws_json1_1DeleteEntitlementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2385,10 +2405,12 @@ const deserializeAws_json1_1DeleteEntitlementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2420,8 +2442,7 @@ const deserializeAws_json1_1DeleteFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2434,10 +2455,12 @@ const deserializeAws_json1_1DeleteFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2469,8 +2492,7 @@ const deserializeAws_json1_1DeleteImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2486,10 +2508,12 @@ const deserializeAws_json1_1DeleteImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2521,8 +2545,7 @@ const deserializeAws_json1_1DeleteImageBuilderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2535,10 +2558,12 @@ const deserializeAws_json1_1DeleteImageBuilderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2570,8 +2595,7 @@ const deserializeAws_json1_1DeleteImagePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotAvailableException": case "com.amazonaws.appstream#ResourceNotAvailableException": @@ -2581,10 +2605,12 @@ const deserializeAws_json1_1DeleteImagePermissionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2616,8 +2642,7 @@ const deserializeAws_json1_1DeleteStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -2633,10 +2658,12 @@ const deserializeAws_json1_1DeleteStackCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2668,8 +2695,7 @@ const deserializeAws_json1_1DeleteUsageReportSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -2679,10 +2705,12 @@ const deserializeAws_json1_1DeleteUsageReportSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2714,18 +2742,19 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2757,8 +2786,7 @@ const deserializeAws_json1_1DescribeAppBlocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.appstream#OperationNotPermittedException": @@ -2768,10 +2796,12 @@ const deserializeAws_json1_1DescribeAppBlocksCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2803,8 +2833,7 @@ const deserializeAws_json1_1DescribeApplicationFleetAssociationsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -2814,10 +2843,12 @@ const deserializeAws_json1_1DescribeApplicationFleetAssociationsCommandError = a throw await deserializeAws_json1_1OperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2849,8 +2880,7 @@ const deserializeAws_json1_1DescribeApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.appstream#OperationNotPermittedException": @@ -2860,10 +2890,12 @@ const deserializeAws_json1_1DescribeApplicationsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2895,18 +2927,19 @@ const deserializeAws_json1_1DescribeDirectoryConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2938,8 +2971,7 @@ const deserializeAws_json1_1DescribeEntitlementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntitlementNotFoundException": case "com.amazonaws.appstream#EntitlementNotFoundException": @@ -2952,10 +2984,12 @@ const deserializeAws_json1_1DescribeEntitlementsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2987,18 +3021,19 @@ const deserializeAws_json1_1DescribeFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3030,18 +3065,19 @@ const deserializeAws_json1_1DescribeImageBuildersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3073,18 +3109,19 @@ const deserializeAws_json1_1DescribeImagePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3116,8 +3153,7 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -3127,10 +3163,12 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3162,18 +3200,19 @@ const deserializeAws_json1_1DescribeSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": throw await deserializeAws_json1_1InvalidParameterCombinationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3205,18 +3244,19 @@ const deserializeAws_json1_1DescribeStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3248,8 +3288,7 @@ const deserializeAws_json1_1DescribeUsageReportSubscriptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -3259,10 +3298,12 @@ const deserializeAws_json1_1DescribeUsageReportSubscriptionsCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3294,8 +3335,7 @@ const deserializeAws_json1_1DescribeUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -3308,10 +3348,12 @@ const deserializeAws_json1_1DescribeUsersCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3343,8 +3385,7 @@ const deserializeAws_json1_1DescribeUserStackAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.appstream#InvalidParameterCombinationException": @@ -3354,10 +3395,12 @@ const deserializeAws_json1_1DescribeUserStackAssociationsCommandError = async ( throw await deserializeAws_json1_1OperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3389,18 +3432,19 @@ const deserializeAws_json1_1DisableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3432,8 +3476,7 @@ const deserializeAws_json1_1DisassociateApplicationFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -3446,10 +3489,12 @@ const deserializeAws_json1_1DisassociateApplicationFleetCommandError = async ( throw await deserializeAws_json1_1OperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3481,8 +3526,7 @@ const deserializeAws_json1_1DisassociateApplicationFromEntitlementCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntitlementNotFoundException": case "com.amazonaws.appstream#EntitlementNotFoundException": @@ -3495,10 +3539,12 @@ const deserializeAws_json1_1DisassociateApplicationFromEntitlementCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3530,8 +3576,7 @@ const deserializeAws_json1_1DisassociateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -3547,10 +3592,12 @@ const deserializeAws_json1_1DisassociateFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3582,8 +3629,7 @@ const deserializeAws_json1_1EnableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -3593,10 +3639,12 @@ const deserializeAws_json1_1EnableUserCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3628,15 +3676,16 @@ const deserializeAws_json1_1ExpireSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3668,15 +3717,16 @@ const deserializeAws_json1_1ListAssociatedFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3708,15 +3758,16 @@ const deserializeAws_json1_1ListAssociatedStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3748,8 +3799,7 @@ const deserializeAws_json1_1ListEntitledApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntitlementNotFoundException": case "com.amazonaws.appstream#EntitlementNotFoundException": @@ -3762,10 +3812,12 @@ const deserializeAws_json1_1ListEntitledApplicationsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3797,18 +3849,19 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3840,8 +3893,7 @@ const deserializeAws_json1_1StartFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -3869,10 +3921,12 @@ const deserializeAws_json1_1StartFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3904,8 +3958,7 @@ const deserializeAws_json1_1StartImageBuilderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -3924,10 +3977,12 @@ const deserializeAws_json1_1StartImageBuilderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3959,8 +4014,7 @@ const deserializeAws_json1_1StopFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -3970,10 +4024,12 @@ const deserializeAws_json1_1StopFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4005,8 +4061,7 @@ const deserializeAws_json1_1StopImageBuilderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4019,10 +4074,12 @@ const deserializeAws_json1_1StopImageBuilderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4054,8 +4111,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAccountStatusException": case "com.amazonaws.appstream#InvalidAccountStatusException": @@ -4068,10 +4124,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4103,18 +4161,19 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.appstream#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4146,8 +4205,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4160,10 +4218,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4195,8 +4255,7 @@ const deserializeAws_json1_1UpdateDirectoryConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4215,10 +4274,12 @@ const deserializeAws_json1_1UpdateDirectoryConfigCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4250,8 +4311,7 @@ const deserializeAws_json1_1UpdateEntitlementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4267,10 +4327,12 @@ const deserializeAws_json1_1UpdateEntitlementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4302,8 +4364,7 @@ const deserializeAws_json1_1UpdateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4340,10 +4401,12 @@ const deserializeAws_json1_1UpdateFleetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4375,8 +4438,7 @@ const deserializeAws_json1_1UpdateImagePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.appstream#LimitExceededException": @@ -4389,10 +4451,12 @@ const deserializeAws_json1_1UpdateImagePermissionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4424,8 +4488,7 @@ const deserializeAws_json1_1UpdateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appstream#ConcurrentModificationException": @@ -4456,10 +4519,12 @@ const deserializeAws_json1_1UpdateStackCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7630,7 +7695,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7656,6 +7721,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-appsync/src/protocols/Aws_restJson1.ts b/clients/client-appsync/src/protocols/Aws_restJson1.ts index f9070df0d0e23..51e332495df17 100644 --- a/clients/client-appsync/src/protocols/Aws_restJson1.ts +++ b/clients/client-appsync/src/protocols/Aws_restJson1.ts @@ -2049,8 +2049,7 @@ const deserializeAws_restJson1AssociateApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -2066,10 +2065,12 @@ const deserializeAws_restJson1AssociateApiCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2102,8 +2103,7 @@ const deserializeAws_restJson1CreateApiCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2122,10 +2122,12 @@ const deserializeAws_restJson1CreateApiCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2158,8 +2160,7 @@ const deserializeAws_restJson1CreateApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApiKeyLimitExceededException": case "com.amazonaws.appsync#ApiKeyLimitExceededException": @@ -2184,10 +2185,12 @@ const deserializeAws_restJson1CreateApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2220,8 +2223,7 @@ const deserializeAws_restJson1CreateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2240,10 +2242,12 @@ const deserializeAws_restJson1CreateDataSourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2276,8 +2280,7 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -2290,10 +2293,12 @@ const deserializeAws_restJson1CreateDomainNameCommandError = async ( throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2326,8 +2331,7 @@ const deserializeAws_restJson1CreateFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -2343,10 +2347,12 @@ const deserializeAws_restJson1CreateFunctionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2379,8 +2385,7 @@ const deserializeAws_restJson1CreateGraphqlApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApiLimitExceededException": case "com.amazonaws.appsync#ApiLimitExceededException": @@ -2402,10 +2407,12 @@ const deserializeAws_restJson1CreateGraphqlApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2438,8 +2445,7 @@ const deserializeAws_restJson1CreateResolverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -2455,10 +2461,12 @@ const deserializeAws_restJson1CreateResolverCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2491,8 +2499,7 @@ const deserializeAws_restJson1CreateTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2511,10 +2518,12 @@ const deserializeAws_restJson1CreateTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2543,8 +2552,7 @@ const deserializeAws_restJson1DeleteApiCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2563,10 +2571,12 @@ const deserializeAws_restJson1DeleteApiCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2595,8 +2605,7 @@ const deserializeAws_restJson1DeleteApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2612,10 +2621,12 @@ const deserializeAws_restJson1DeleteApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2644,8 +2655,7 @@ const deserializeAws_restJson1DeleteDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2664,10 +2674,12 @@ const deserializeAws_restJson1DeleteDataSourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2696,8 +2708,7 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -2716,10 +2727,12 @@ const deserializeAws_restJson1DeleteDomainNameCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2748,8 +2761,7 @@ const deserializeAws_restJson1DeleteFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -2765,10 +2777,12 @@ const deserializeAws_restJson1DeleteFunctionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2797,8 +2811,7 @@ const deserializeAws_restJson1DeleteGraphqlApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -2820,10 +2833,12 @@ const deserializeAws_restJson1DeleteGraphqlApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2852,8 +2867,7 @@ const deserializeAws_restJson1DeleteResolverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -2869,10 +2883,12 @@ const deserializeAws_restJson1DeleteResolverCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2901,8 +2917,7 @@ const deserializeAws_restJson1DeleteTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -2921,10 +2936,12 @@ const deserializeAws_restJson1DeleteTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2970,7 @@ const deserializeAws_restJson1DisassociateApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -2973,10 +2989,12 @@ const deserializeAws_restJson1DisassociateApiCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3005,8 +3023,7 @@ const deserializeAws_restJson1FlushApiCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3025,10 +3042,12 @@ const deserializeAws_restJson1FlushApiCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3061,8 +3080,7 @@ const deserializeAws_restJson1GetApiAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -3078,10 +3096,12 @@ const deserializeAws_restJson1GetApiAssociationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3114,8 +3134,7 @@ const deserializeAws_restJson1GetApiCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3134,10 +3153,12 @@ const deserializeAws_restJson1GetApiCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3170,8 +3191,7 @@ const deserializeAws_restJson1GetDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3190,10 +3210,12 @@ const deserializeAws_restJson1GetDataSourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3226,8 +3248,7 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -3243,10 +3264,12 @@ const deserializeAws_restJson1GetDomainNameCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3279,8 +3302,7 @@ const deserializeAws_restJson1GetFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -3293,10 +3315,12 @@ const deserializeAws_restJson1GetFunctionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3329,8 +3353,7 @@ const deserializeAws_restJson1GetGraphqlApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -3349,10 +3372,12 @@ const deserializeAws_restJson1GetGraphqlApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3383,8 +3408,7 @@ const deserializeAws_restJson1GetIntrospectionSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GraphQLSchemaException": case "com.amazonaws.appsync#GraphQLSchemaException": @@ -3400,10 +3424,12 @@ const deserializeAws_restJson1GetIntrospectionSchemaCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3436,8 +3462,7 @@ const deserializeAws_restJson1GetResolverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -3450,10 +3475,12 @@ const deserializeAws_restJson1GetResolverCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3490,8 +3517,7 @@ const deserializeAws_restJson1GetSchemaCreationStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3507,10 +3533,12 @@ const deserializeAws_restJson1GetSchemaCreationStatusCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3543,8 +3571,7 @@ const deserializeAws_restJson1GetTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3563,10 +3590,12 @@ const deserializeAws_restJson1GetTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3603,8 +3632,7 @@ const deserializeAws_restJson1ListApiKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3620,10 +3648,12 @@ const deserializeAws_restJson1ListApiKeysCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3660,8 +3690,7 @@ const deserializeAws_restJson1ListDataSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3677,10 +3706,12 @@ const deserializeAws_restJson1ListDataSourcesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3717,8 +3748,7 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -3731,10 +3761,12 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( throw await deserializeAws_restJson1InternalFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3771,8 +3803,7 @@ const deserializeAws_restJson1ListFunctionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3788,10 +3819,12 @@ const deserializeAws_restJson1ListFunctionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3828,8 +3861,7 @@ const deserializeAws_restJson1ListGraphqlApisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3842,10 +3874,12 @@ const deserializeAws_restJson1ListGraphqlApisCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3882,8 +3916,7 @@ const deserializeAws_restJson1ListResolversCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3899,10 +3932,12 @@ const deserializeAws_restJson1ListResolversCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3939,8 +3974,7 @@ const deserializeAws_restJson1ListResolversByFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -3956,10 +3990,12 @@ const deserializeAws_restJson1ListResolversByFunctionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3992,8 +4028,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -4015,10 +4050,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4055,8 +4092,7 @@ const deserializeAws_restJson1ListTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -4075,10 +4111,12 @@ const deserializeAws_restJson1ListTypesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4111,8 +4149,7 @@ const deserializeAws_restJson1StartSchemaCreationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -4131,10 +4168,12 @@ const deserializeAws_restJson1StartSchemaCreationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4163,8 +4202,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -4186,10 +4224,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4218,8 +4258,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -4241,10 +4280,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4277,8 +4318,7 @@ const deserializeAws_restJson1UpdateApiCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -4297,10 +4337,12 @@ const deserializeAws_restJson1UpdateApiCacheCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4333,8 +4375,7 @@ const deserializeAws_restJson1UpdateApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApiKeyValidityOutOfBoundsException": case "com.amazonaws.appsync#ApiKeyValidityOutOfBoundsException": @@ -4356,10 +4397,12 @@ const deserializeAws_restJson1UpdateApiKeyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4392,8 +4435,7 @@ const deserializeAws_restJson1UpdateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -4412,10 +4454,12 @@ const deserializeAws_restJson1UpdateDataSourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4448,8 +4492,7 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -4468,10 +4511,12 @@ const deserializeAws_restJson1UpdateDomainNameCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4504,8 +4549,7 @@ const deserializeAws_restJson1UpdateFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -4521,10 +4565,12 @@ const deserializeAws_restJson1UpdateFunctionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4557,8 +4603,7 @@ const deserializeAws_restJson1UpdateGraphqlApiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.appsync#AccessDeniedException": @@ -4580,10 +4625,12 @@ const deserializeAws_restJson1UpdateGraphqlApiCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4616,8 +4663,7 @@ const deserializeAws_restJson1UpdateResolverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.appsync#ConcurrentModificationException": @@ -4633,10 +4679,12 @@ const deserializeAws_restJson1UpdateResolverCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4669,8 +4717,7 @@ const deserializeAws_restJson1UpdateTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.appsync#BadRequestException": @@ -4689,10 +4736,12 @@ const deserializeAws_restJson1UpdateTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5703,7 +5752,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5729,6 +5778,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-athena/src/protocols/Aws_json1_1.ts b/clients/client-athena/src/protocols/Aws_json1_1.ts index 6888cb5aa3689..d0fbdc4fdd02f 100644 --- a/clients/client-athena/src/protocols/Aws_json1_1.ts +++ b/clients/client-athena/src/protocols/Aws_json1_1.ts @@ -670,8 +670,7 @@ const deserializeAws_json1_1BatchGetNamedQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -681,10 +680,12 @@ const deserializeAws_json1_1BatchGetNamedQueryCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -716,8 +717,7 @@ const deserializeAws_json1_1BatchGetQueryExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -727,10 +727,12 @@ const deserializeAws_json1_1BatchGetQueryExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -762,8 +764,7 @@ const deserializeAws_json1_1CreateDataCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -773,10 +774,12 @@ const deserializeAws_json1_1CreateDataCatalogCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -808,8 +811,7 @@ const deserializeAws_json1_1CreateNamedQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -819,10 +821,12 @@ const deserializeAws_json1_1CreateNamedQueryCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -854,8 +858,7 @@ const deserializeAws_json1_1CreatePreparedStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -865,10 +868,12 @@ const deserializeAws_json1_1CreatePreparedStatementCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -900,8 +905,7 @@ const deserializeAws_json1_1CreateWorkGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -911,10 +915,12 @@ const deserializeAws_json1_1CreateWorkGroupCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -946,8 +952,7 @@ const deserializeAws_json1_1DeleteDataCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -957,10 +962,12 @@ const deserializeAws_json1_1DeleteDataCatalogCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -992,8 +999,7 @@ const deserializeAws_json1_1DeleteNamedQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1003,10 +1009,12 @@ const deserializeAws_json1_1DeleteNamedQueryCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1038,8 +1046,7 @@ const deserializeAws_json1_1DeletePreparedStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1052,10 +1059,12 @@ const deserializeAws_json1_1DeletePreparedStatementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1087,8 +1096,7 @@ const deserializeAws_json1_1DeleteWorkGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1098,10 +1106,12 @@ const deserializeAws_json1_1DeleteWorkGroupCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1133,8 +1143,7 @@ const deserializeAws_json1_1GetDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1147,10 +1156,12 @@ const deserializeAws_json1_1GetDatabaseCommandError = async ( throw await deserializeAws_json1_1MetadataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1193,7 @@ const deserializeAws_json1_1GetDataCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1193,10 +1203,12 @@ const deserializeAws_json1_1GetDataCatalogCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1228,8 +1240,7 @@ const deserializeAws_json1_1GetNamedQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1239,10 +1250,12 @@ const deserializeAws_json1_1GetNamedQueryCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1274,8 +1287,7 @@ const deserializeAws_json1_1GetPreparedStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1288,10 +1300,12 @@ const deserializeAws_json1_1GetPreparedStatementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1323,8 +1337,7 @@ const deserializeAws_json1_1GetQueryExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1334,10 +1347,12 @@ const deserializeAws_json1_1GetQueryExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1369,8 +1384,7 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1380,10 +1394,12 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1415,8 +1431,7 @@ const deserializeAws_json1_1GetTableMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1429,10 +1444,12 @@ const deserializeAws_json1_1GetTableMetadataCommandError = async ( throw await deserializeAws_json1_1MetadataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1464,8 +1481,7 @@ const deserializeAws_json1_1GetWorkGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1475,10 +1491,12 @@ const deserializeAws_json1_1GetWorkGroupCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1510,8 +1528,7 @@ const deserializeAws_json1_1ListDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1524,10 +1541,12 @@ const deserializeAws_json1_1ListDatabasesCommandError = async ( throw await deserializeAws_json1_1MetadataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1559,8 +1578,7 @@ const deserializeAws_json1_1ListDataCatalogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1570,10 +1588,12 @@ const deserializeAws_json1_1ListDataCatalogsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1605,8 +1625,7 @@ const deserializeAws_json1_1ListEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1616,10 +1635,12 @@ const deserializeAws_json1_1ListEngineVersionsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1672,7 @@ const deserializeAws_json1_1ListNamedQueriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1662,10 +1682,12 @@ const deserializeAws_json1_1ListNamedQueriesCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1697,8 +1719,7 @@ const deserializeAws_json1_1ListPreparedStatementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1708,10 +1729,12 @@ const deserializeAws_json1_1ListPreparedStatementsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1743,8 +1766,7 @@ const deserializeAws_json1_1ListQueryExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1754,10 +1776,12 @@ const deserializeAws_json1_1ListQueryExecutionsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1789,8 +1813,7 @@ const deserializeAws_json1_1ListTableMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1803,10 +1826,12 @@ const deserializeAws_json1_1ListTableMetadataCommandError = async ( throw await deserializeAws_json1_1MetadataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1838,8 +1863,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1852,10 +1876,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1887,8 +1913,7 @@ const deserializeAws_json1_1ListWorkGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1898,10 +1923,12 @@ const deserializeAws_json1_1ListWorkGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1933,8 +1960,7 @@ const deserializeAws_json1_1StartQueryExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1947,10 +1973,12 @@ const deserializeAws_json1_1StartQueryExecutionCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1982,8 +2010,7 @@ const deserializeAws_json1_1StopQueryExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -1993,10 +2020,12 @@ const deserializeAws_json1_1StopQueryExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2028,8 +2057,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2042,10 +2070,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,8 +2107,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2091,10 +2120,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2126,8 +2157,7 @@ const deserializeAws_json1_1UpdateDataCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2137,10 +2167,12 @@ const deserializeAws_json1_1UpdateDataCatalogCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2172,8 +2204,7 @@ const deserializeAws_json1_1UpdateNamedQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2183,10 +2214,12 @@ const deserializeAws_json1_1UpdateNamedQueryCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2218,8 +2251,7 @@ const deserializeAws_json1_1UpdatePreparedStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2232,10 +2264,12 @@ const deserializeAws_json1_1UpdatePreparedStatementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2267,8 +2301,7 @@ const deserializeAws_json1_1UpdateWorkGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.athena#InternalServerException": @@ -2278,10 +2311,12 @@ const deserializeAws_json1_1UpdateWorkGroupCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3856,7 +3891,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3882,6 +3917,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-auditmanager/src/protocols/Aws_restJson1.ts b/clients/client-auditmanager/src/protocols/Aws_restJson1.ts index a89b3773784fb..838ed0fb609a2 100644 --- a/clients/client-auditmanager/src/protocols/Aws_restJson1.ts +++ b/clients/client-auditmanager/src/protocols/Aws_restJson1.ts @@ -2305,8 +2305,7 @@ const deserializeAws_restJson1AssociateAssessmentReportEvidenceFolderCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2322,10 +2321,12 @@ const deserializeAws_restJson1AssociateAssessmentReportEvidenceFolderCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2362,8 +2363,7 @@ const deserializeAws_restJson1BatchAssociateAssessmentReportEvidenceCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2379,10 +2379,12 @@ const deserializeAws_restJson1BatchAssociateAssessmentReportEvidenceCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2419,8 +2421,7 @@ const deserializeAws_restJson1BatchCreateDelegationByAssessmentCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2436,10 +2437,12 @@ const deserializeAws_restJson1BatchCreateDelegationByAssessmentCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2472,8 +2475,7 @@ const deserializeAws_restJson1BatchDeleteDelegationByAssessmentCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2489,10 +2491,12 @@ const deserializeAws_restJson1BatchDeleteDelegationByAssessmentCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2529,8 +2533,7 @@ const deserializeAws_restJson1BatchDisassociateAssessmentReportEvidenceCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2546,10 +2549,12 @@ const deserializeAws_restJson1BatchDisassociateAssessmentReportEvidenceCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2582,8 +2587,7 @@ const deserializeAws_restJson1BatchImportEvidenceToAssessmentControlCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2599,10 +2603,12 @@ const deserializeAws_restJson1BatchImportEvidenceToAssessmentControlCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2635,8 +2641,7 @@ const deserializeAws_restJson1CreateAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2652,10 +2657,12 @@ const deserializeAws_restJson1CreateAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2688,8 +2695,7 @@ const deserializeAws_restJson1CreateAssessmentFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2705,10 +2711,12 @@ const deserializeAws_restJson1CreateAssessmentFrameworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2741,8 +2749,7 @@ const deserializeAws_restJson1CreateAssessmentReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2758,10 +2765,12 @@ const deserializeAws_restJson1CreateAssessmentReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2794,8 +2803,7 @@ const deserializeAws_restJson1CreateControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2811,10 +2819,12 @@ const deserializeAws_restJson1CreateControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2843,8 +2853,7 @@ const deserializeAws_restJson1DeleteAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2860,10 +2869,12 @@ const deserializeAws_restJson1DeleteAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2892,8 +2903,7 @@ const deserializeAws_restJson1DeleteAssessmentFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2909,10 +2919,12 @@ const deserializeAws_restJson1DeleteAssessmentFrameworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2941,8 +2953,7 @@ const deserializeAws_restJson1DeleteAssessmentFrameworkShareCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -2958,10 +2969,12 @@ const deserializeAws_restJson1DeleteAssessmentFrameworkShareCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2990,8 +3003,7 @@ const deserializeAws_restJson1DeleteAssessmentReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3007,10 +3019,12 @@ const deserializeAws_restJson1DeleteAssessmentReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3039,8 +3053,7 @@ const deserializeAws_restJson1DeleteControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3056,10 +3069,12 @@ const deserializeAws_restJson1DeleteControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3092,8 +3107,7 @@ const deserializeAws_restJson1DeregisterAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3109,10 +3123,12 @@ const deserializeAws_restJson1DeregisterAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3141,8 +3157,7 @@ const deserializeAws_restJson1DeregisterOrganizationAdminAccountCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3158,10 +3173,12 @@ const deserializeAws_restJson1DeregisterOrganizationAdminAccountCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3190,8 +3207,7 @@ const deserializeAws_restJson1DisassociateAssessmentReportEvidenceFolderCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3207,10 +3223,12 @@ const deserializeAws_restJson1DisassociateAssessmentReportEvidenceFolderCommandE throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3243,18 +3261,19 @@ const deserializeAws_restJson1GetAccountStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.auditmanager#InternalServerException": throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3291,8 +3310,7 @@ const deserializeAws_restJson1GetAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3308,10 +3326,12 @@ const deserializeAws_restJson1GetAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3344,8 +3364,7 @@ const deserializeAws_restJson1GetAssessmentFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3361,10 +3380,12 @@ const deserializeAws_restJson1GetAssessmentFrameworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3397,8 +3418,7 @@ const deserializeAws_restJson1GetAssessmentReportUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3414,10 +3434,12 @@ const deserializeAws_restJson1GetAssessmentReportUrlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3454,8 +3476,7 @@ const deserializeAws_restJson1GetChangeLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3471,10 +3492,12 @@ const deserializeAws_restJson1GetChangeLogsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3507,8 +3530,7 @@ const deserializeAws_restJson1GetControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3524,10 +3546,12 @@ const deserializeAws_restJson1GetControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3564,8 +3588,7 @@ const deserializeAws_restJson1GetDelegationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3578,10 +3601,12 @@ const deserializeAws_restJson1GetDelegationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3614,8 +3639,7 @@ const deserializeAws_restJson1GetEvidenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3631,10 +3655,12 @@ const deserializeAws_restJson1GetEvidenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3671,8 +3697,7 @@ const deserializeAws_restJson1GetEvidenceByEvidenceFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3688,10 +3713,12 @@ const deserializeAws_restJson1GetEvidenceByEvidenceFolderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3724,8 +3751,7 @@ const deserializeAws_restJson1GetEvidenceFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3741,10 +3767,12 @@ const deserializeAws_restJson1GetEvidenceFolderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3781,8 +3809,7 @@ const deserializeAws_restJson1GetEvidenceFoldersByAssessmentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3798,10 +3825,12 @@ const deserializeAws_restJson1GetEvidenceFoldersByAssessmentCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3838,8 +3867,7 @@ const deserializeAws_restJson1GetEvidenceFoldersByAssessmentControlCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3855,10 +3883,12 @@ const deserializeAws_restJson1GetEvidenceFoldersByAssessmentControlCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3891,8 +3921,7 @@ const deserializeAws_restJson1GetInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3902,10 +3931,12 @@ const deserializeAws_restJson1GetInsightsCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3938,8 +3969,7 @@ const deserializeAws_restJson1GetInsightsByAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -3955,10 +3985,12 @@ const deserializeAws_restJson1GetInsightsByAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3995,8 +4027,7 @@ const deserializeAws_restJson1GetOrganizationAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4012,10 +4043,12 @@ const deserializeAws_restJson1GetOrganizationAdminAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4048,8 +4081,7 @@ const deserializeAws_restJson1GetServicesInScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4062,10 +4094,12 @@ const deserializeAws_restJson1GetServicesInScopeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4098,8 +4132,7 @@ const deserializeAws_restJson1GetSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4109,10 +4142,12 @@ const deserializeAws_restJson1GetSettingsCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4152,8 +4187,7 @@ const deserializeAws_restJson1ListAssessmentControlInsightsByControlDomainComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4169,10 +4203,12 @@ const deserializeAws_restJson1ListAssessmentControlInsightsByControlDomainComman throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4209,8 +4245,7 @@ const deserializeAws_restJson1ListAssessmentFrameworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4223,10 +4258,12 @@ const deserializeAws_restJson1ListAssessmentFrameworksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4266,8 +4303,7 @@ const deserializeAws_restJson1ListAssessmentFrameworkShareRequestsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4280,10 +4316,12 @@ const deserializeAws_restJson1ListAssessmentFrameworkShareRequestsCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4320,8 +4358,7 @@ const deserializeAws_restJson1ListAssessmentReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4334,10 +4371,12 @@ const deserializeAws_restJson1ListAssessmentReportsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4374,8 +4413,7 @@ const deserializeAws_restJson1ListAssessmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4388,10 +4426,12 @@ const deserializeAws_restJson1ListAssessmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4431,8 +4471,7 @@ const deserializeAws_restJson1ListControlDomainInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4448,10 +4487,12 @@ const deserializeAws_restJson1ListControlDomainInsightsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4491,8 +4532,7 @@ const deserializeAws_restJson1ListControlDomainInsightsByAssessmentCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4508,10 +4548,12 @@ const deserializeAws_restJson1ListControlDomainInsightsByAssessmentCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4551,8 +4593,7 @@ const deserializeAws_restJson1ListControlInsightsByControlDomainCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4568,10 +4609,12 @@ const deserializeAws_restJson1ListControlInsightsByControlDomainCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4608,8 +4651,7 @@ const deserializeAws_restJson1ListControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4622,10 +4664,12 @@ const deserializeAws_restJson1ListControlsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4662,8 +4706,7 @@ const deserializeAws_restJson1ListKeywordsForDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4676,10 +4719,12 @@ const deserializeAws_restJson1ListKeywordsForDataSourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4716,8 +4761,7 @@ const deserializeAws_restJson1ListNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4730,10 +4774,12 @@ const deserializeAws_restJson1ListNotificationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4766,8 +4812,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.auditmanager#InternalServerException": @@ -4780,10 +4825,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4816,8 +4863,7 @@ const deserializeAws_restJson1RegisterAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4836,10 +4882,12 @@ const deserializeAws_restJson1RegisterAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4876,8 +4924,7 @@ const deserializeAws_restJson1RegisterOrganizationAdminAccountCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4893,10 +4940,12 @@ const deserializeAws_restJson1RegisterOrganizationAdminAccountCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4932,8 +4981,7 @@ const deserializeAws_restJson1StartAssessmentFrameworkShareCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -4949,10 +4997,12 @@ const deserializeAws_restJson1StartAssessmentFrameworkShareCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4981,8 +5031,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.auditmanager#InternalServerException": @@ -4995,10 +5044,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5027,8 +5078,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.auditmanager#InternalServerException": @@ -5041,10 +5091,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5077,8 +5129,7 @@ const deserializeAws_restJson1UpdateAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5094,10 +5145,12 @@ const deserializeAws_restJson1UpdateAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5130,8 +5183,7 @@ const deserializeAws_restJson1UpdateAssessmentControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5147,10 +5199,12 @@ const deserializeAws_restJson1UpdateAssessmentControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5183,8 +5237,7 @@ const deserializeAws_restJson1UpdateAssessmentControlSetStatusCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5200,10 +5253,12 @@ const deserializeAws_restJson1UpdateAssessmentControlSetStatusCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5236,8 +5291,7 @@ const deserializeAws_restJson1UpdateAssessmentFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5253,10 +5307,12 @@ const deserializeAws_restJson1UpdateAssessmentFrameworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5292,8 +5348,7 @@ const deserializeAws_restJson1UpdateAssessmentFrameworkShareCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5309,10 +5364,12 @@ const deserializeAws_restJson1UpdateAssessmentFrameworkShareCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5345,8 +5402,7 @@ const deserializeAws_restJson1UpdateAssessmentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5362,10 +5418,12 @@ const deserializeAws_restJson1UpdateAssessmentStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5398,8 +5456,7 @@ const deserializeAws_restJson1UpdateControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5415,10 +5472,12 @@ const deserializeAws_restJson1UpdateControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5451,8 +5510,7 @@ const deserializeAws_restJson1UpdateSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5465,10 +5523,12 @@ const deserializeAws_restJson1UpdateSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5517,8 +5577,7 @@ const deserializeAws_restJson1ValidateAssessmentReportIntegrityCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.auditmanager#AccessDeniedException": @@ -5534,10 +5593,12 @@ const deserializeAws_restJson1ValidateAssessmentReportIntegrityCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7198,7 +7259,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7224,6 +7285,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-auto-scaling-plans/src/protocols/Aws_json1_1.ts b/clients/client-auto-scaling-plans/src/protocols/Aws_json1_1.ts index dda384deb0841..74ef559b166ac 100644 --- a/clients/client-auto-scaling-plans/src/protocols/Aws_json1_1.ts +++ b/clients/client-auto-scaling-plans/src/protocols/Aws_json1_1.ts @@ -173,8 +173,7 @@ const deserializeAws_json1_1CreateScalingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.autoscalingplans#ConcurrentUpdateException": @@ -190,10 +189,12 @@ const deserializeAws_json1_1CreateScalingPlanCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -225,8 +226,7 @@ const deserializeAws_json1_1DeleteScalingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.autoscalingplans#ConcurrentUpdateException": @@ -242,10 +242,12 @@ const deserializeAws_json1_1DeleteScalingPlanCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -277,8 +279,7 @@ const deserializeAws_json1_1DescribeScalingPlanResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.autoscalingplans#ConcurrentUpdateException": @@ -294,10 +295,12 @@ const deserializeAws_json1_1DescribeScalingPlanResourcesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -329,8 +332,7 @@ const deserializeAws_json1_1DescribeScalingPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.autoscalingplans#ConcurrentUpdateException": @@ -346,10 +348,12 @@ const deserializeAws_json1_1DescribeScalingPlansCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -381,8 +385,7 @@ const deserializeAws_json1_1GetScalingPlanResourceForecastDataCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.autoscalingplans#InternalServiceException": @@ -392,10 +395,12 @@ const deserializeAws_json1_1GetScalingPlanResourceForecastDataCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -427,8 +432,7 @@ const deserializeAws_json1_1UpdateScalingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentUpdateException": case "com.amazonaws.autoscalingplans#ConcurrentUpdateException": @@ -444,10 +448,12 @@ const deserializeAws_json1_1UpdateScalingPlanCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1344,7 +1350,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1370,6 +1376,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-auto-scaling/src/protocols/Aws_query.ts b/clients/client-auto-scaling/src/protocols/Aws_query.ts index 8f35b95fd9c26..27115abcc7402 100644 --- a/clients/client-auto-scaling/src/protocols/Aws_query.ts +++ b/clients/client-auto-scaling/src/protocols/Aws_query.ts @@ -1375,8 +1375,7 @@ const deserializeAws_queryAttachInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -1386,10 +1385,12 @@ const deserializeAws_queryAttachInstancesCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1421,8 +1422,7 @@ const deserializeAws_queryAttachLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -1432,10 +1432,12 @@ const deserializeAws_queryAttachLoadBalancersCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1470,8 +1472,7 @@ const deserializeAws_queryAttachLoadBalancerTargetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -1481,10 +1482,12 @@ const deserializeAws_queryAttachLoadBalancerTargetGroupsCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1516,18 +1519,19 @@ const deserializeAws_queryBatchDeleteScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1562,8 +1566,7 @@ const deserializeAws_queryBatchPutScheduledUpdateGroupActionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsFault": case "com.amazonaws.autoscaling#AlreadyExistsFault": @@ -1576,10 +1579,12 @@ const deserializeAws_queryBatchPutScheduledUpdateGroupActionCommandError = async throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1611,8 +1616,7 @@ const deserializeAws_queryCancelInstanceRefreshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveInstanceRefreshNotFoundFault": case "com.amazonaws.autoscaling#ActiveInstanceRefreshNotFoundFault": @@ -1625,10 +1629,12 @@ const deserializeAws_queryCancelInstanceRefreshCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1660,18 +1666,19 @@ const deserializeAws_queryCompleteLifecycleActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1700,8 +1707,7 @@ const deserializeAws_queryCreateAutoScalingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsFault": case "com.amazonaws.autoscaling#AlreadyExistsFault": @@ -1717,10 +1723,12 @@ const deserializeAws_queryCreateAutoScalingGroupCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1749,8 +1757,7 @@ const deserializeAws_queryCreateLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsFault": case "com.amazonaws.autoscaling#AlreadyExistsFault": @@ -1763,10 +1770,12 @@ const deserializeAws_queryCreateLaunchConfigurationCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1795,8 +1804,7 @@ const deserializeAws_queryCreateOrUpdateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsFault": case "com.amazonaws.autoscaling#AlreadyExistsFault": @@ -1812,10 +1820,12 @@ const deserializeAws_queryCreateOrUpdateTagsCommandError = async ( throw await deserializeAws_queryResourceInUseFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1844,8 +1854,7 @@ const deserializeAws_queryDeleteAutoScalingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -1858,10 +1867,12 @@ const deserializeAws_queryDeleteAutoScalingGroupCommandError = async ( throw await deserializeAws_queryScalingActivityInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1890,8 +1901,7 @@ const deserializeAws_queryDeleteLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -1901,10 +1911,12 @@ const deserializeAws_queryDeleteLaunchConfigurationCommandError = async ( throw await deserializeAws_queryResourceInUseFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1936,18 +1948,19 @@ const deserializeAws_queryDeleteLifecycleHookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1976,18 +1989,19 @@ const deserializeAws_queryDeleteNotificationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2016,8 +2030,7 @@ const deserializeAws_queryDeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -2027,10 +2040,12 @@ const deserializeAws_queryDeletePolicyCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2059,18 +2074,19 @@ const deserializeAws_queryDeleteScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2099,8 +2115,7 @@ const deserializeAws_queryDeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -2110,10 +2125,12 @@ const deserializeAws_queryDeleteTagsCommandError = async ( throw await deserializeAws_queryResourceInUseFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2145,8 +2162,7 @@ const deserializeAws_queryDeleteWarmPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -2162,10 +2178,12 @@ const deserializeAws_queryDeleteWarmPoolCommandError = async ( throw await deserializeAws_queryScalingActivityInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2197,18 +2215,19 @@ const deserializeAws_queryDescribeAccountLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2240,18 +2259,19 @@ const deserializeAws_queryDescribeAdjustmentTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2283,8 +2303,7 @@ const deserializeAws_queryDescribeAutoScalingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2294,10 +2313,12 @@ const deserializeAws_queryDescribeAutoScalingGroupsCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2329,8 +2350,7 @@ const deserializeAws_queryDescribeAutoScalingInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2340,10 +2360,12 @@ const deserializeAws_queryDescribeAutoScalingInstancesCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2378,18 +2400,19 @@ const deserializeAws_queryDescribeAutoScalingNotificationTypesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2421,8 +2444,7 @@ const deserializeAws_queryDescribeInstanceRefreshesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2432,10 +2454,12 @@ const deserializeAws_queryDescribeInstanceRefreshesCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2467,8 +2491,7 @@ const deserializeAws_queryDescribeLaunchConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2478,10 +2501,12 @@ const deserializeAws_queryDescribeLaunchConfigurationsCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2513,18 +2538,19 @@ const deserializeAws_queryDescribeLifecycleHooksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2556,18 +2582,19 @@ const deserializeAws_queryDescribeLifecycleHookTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2599,8 +2626,7 @@ const deserializeAws_queryDescribeLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2610,10 +2636,12 @@ const deserializeAws_queryDescribeLoadBalancersCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2648,8 +2676,7 @@ const deserializeAws_queryDescribeLoadBalancerTargetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2659,10 +2686,12 @@ const deserializeAws_queryDescribeLoadBalancerTargetGroupsCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2694,18 +2723,19 @@ const deserializeAws_queryDescribeMetricCollectionTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2740,8 +2770,7 @@ const deserializeAws_queryDescribeNotificationConfigurationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2751,10 +2780,12 @@ const deserializeAws_queryDescribeNotificationConfigurationsCommandError = async throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2786,8 +2817,7 @@ const deserializeAws_queryDescribePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2800,10 +2830,12 @@ const deserializeAws_queryDescribePoliciesCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2835,8 +2867,7 @@ const deserializeAws_queryDescribeScalingActivitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2846,10 +2877,12 @@ const deserializeAws_queryDescribeScalingActivitiesCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2881,18 +2914,19 @@ const deserializeAws_queryDescribeScalingProcessTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2924,8 +2958,7 @@ const deserializeAws_queryDescribeScheduledActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2935,10 +2968,12 @@ const deserializeAws_queryDescribeScheduledActionsCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2970,8 +3005,7 @@ const deserializeAws_queryDescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -2981,10 +3015,12 @@ const deserializeAws_queryDescribeTagsCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3019,18 +3055,19 @@ const deserializeAws_queryDescribeTerminationPolicyTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3062,8 +3099,7 @@ const deserializeAws_queryDescribeWarmPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.autoscaling#InvalidNextToken": @@ -3076,10 +3112,12 @@ const deserializeAws_queryDescribeWarmPoolCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3111,18 +3149,19 @@ const deserializeAws_queryDetachInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3154,18 +3193,19 @@ const deserializeAws_queryDetachLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3200,18 +3240,19 @@ const deserializeAws_queryDetachLoadBalancerTargetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3240,18 +3281,19 @@ const deserializeAws_queryDisableMetricsCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3280,18 +3322,19 @@ const deserializeAws_queryEnableMetricsCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3323,18 +3366,19 @@ const deserializeAws_queryEnterStandbyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3363,8 +3407,7 @@ const deserializeAws_queryExecutePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -3374,10 +3417,12 @@ const deserializeAws_queryExecutePolicyCommandError = async ( throw await deserializeAws_queryScalingActivityInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3409,18 +3454,19 @@ const deserializeAws_queryExitStandbyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3452,18 +3498,19 @@ const deserializeAws_queryGetPredictiveScalingForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3495,8 +3542,7 @@ const deserializeAws_queryPutLifecycleHookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -3506,10 +3552,12 @@ const deserializeAws_queryPutLifecycleHookCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3538,8 +3586,7 @@ const deserializeAws_queryPutNotificationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -3552,10 +3599,12 @@ const deserializeAws_queryPutNotificationConfigurationCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3587,8 +3636,7 @@ const deserializeAws_queryPutScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -3601,10 +3649,12 @@ const deserializeAws_queryPutScalingPolicyCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3633,8 +3683,7 @@ const deserializeAws_queryPutScheduledUpdateGroupActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsFault": case "com.amazonaws.autoscaling#AlreadyExistsFault": @@ -3647,10 +3696,12 @@ const deserializeAws_queryPutScheduledUpdateGroupActionCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3682,8 +3733,7 @@ const deserializeAws_queryPutWarmPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -3693,10 +3743,12 @@ const deserializeAws_queryPutWarmPoolCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3731,18 +3783,19 @@ const deserializeAws_queryRecordLifecycleActionHeartbeatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3771,8 +3824,7 @@ const deserializeAws_queryResumeProcessesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -3782,10 +3834,12 @@ const deserializeAws_queryResumeProcessesCommandError = async ( throw await deserializeAws_queryResourceInUseFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3814,8 +3868,7 @@ const deserializeAws_querySetDesiredCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -3825,10 +3878,12 @@ const deserializeAws_querySetDesiredCapacityCommandError = async ( throw await deserializeAws_queryScalingActivityInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3857,18 +3912,19 @@ const deserializeAws_querySetInstanceHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3900,8 +3956,7 @@ const deserializeAws_querySetInstanceProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.autoscaling#LimitExceededFault": @@ -3911,10 +3966,12 @@ const deserializeAws_querySetInstanceProtectionCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3946,8 +4003,7 @@ const deserializeAws_queryStartInstanceRefreshCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceRefreshInProgressFault": case "com.amazonaws.autoscaling#InstanceRefreshInProgressFault": @@ -3960,10 +4016,12 @@ const deserializeAws_queryStartInstanceRefreshCommandError = async ( throw await deserializeAws_queryResourceContentionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3992,8 +4050,7 @@ const deserializeAws_querySuspendProcessesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -4003,10 +4060,12 @@ const deserializeAws_querySuspendProcessesCommandError = async ( throw await deserializeAws_queryResourceInUseFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4038,8 +4097,7 @@ const deserializeAws_queryTerminateInstanceInAutoScalingGroupCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -4049,10 +4107,12 @@ const deserializeAws_queryTerminateInstanceInAutoScalingGroupCommandError = asyn throw await deserializeAws_queryScalingActivityInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4081,8 +4141,7 @@ const deserializeAws_queryUpdateAutoScalingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceContentionFault": case "com.amazonaws.autoscaling#ResourceContentionFault": @@ -4095,10 +4154,12 @@ const deserializeAws_queryUpdateAutoScalingGroupCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleFailureResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10126,12 +10187,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-backup-gateway/src/protocols/Aws_json1_0.ts b/clients/client-backup-gateway/src/protocols/Aws_json1_0.ts index 766c2e6f7eed1..18d9977af2b06 100644 --- a/clients/client-backup-gateway/src/protocols/Aws_json1_0.ts +++ b/clients/client-backup-gateway/src/protocols/Aws_json1_0.ts @@ -369,8 +369,7 @@ const deserializeAws_json1_0AssociateGatewayToServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backupgateway#ConflictException": @@ -383,10 +382,12 @@ const deserializeAws_json1_0AssociateGatewayToServerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -418,8 +419,7 @@ const deserializeAws_json1_0CreateGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -429,10 +429,12 @@ const deserializeAws_json1_0CreateGatewayCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -464,8 +466,7 @@ const deserializeAws_json1_0DeleteGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -478,10 +479,12 @@ const deserializeAws_json1_0DeleteGatewayCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -513,8 +516,7 @@ const deserializeAws_json1_0DeleteHypervisorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.backupgateway#AccessDeniedException": @@ -530,10 +532,12 @@ const deserializeAws_json1_0DeleteHypervisorCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -565,8 +569,7 @@ const deserializeAws_json1_0DisassociateGatewayFromServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backupgateway#ConflictException": @@ -582,10 +585,12 @@ const deserializeAws_json1_0DisassociateGatewayFromServerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -617,8 +622,7 @@ const deserializeAws_json1_0GetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -631,10 +635,12 @@ const deserializeAws_json1_0GetGatewayCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -666,8 +672,7 @@ const deserializeAws_json1_0ImportHypervisorConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.backupgateway#AccessDeniedException": @@ -680,10 +685,12 @@ const deserializeAws_json1_0ImportHypervisorConfigurationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -715,8 +722,7 @@ const deserializeAws_json1_0ListGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -726,10 +732,12 @@ const deserializeAws_json1_0ListGatewaysCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -761,8 +769,7 @@ const deserializeAws_json1_0ListHypervisorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -772,10 +779,12 @@ const deserializeAws_json1_0ListHypervisorsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -807,8 +816,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -821,10 +829,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -856,8 +866,7 @@ const deserializeAws_json1_0ListVirtualMachinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -867,10 +876,12 @@ const deserializeAws_json1_0ListVirtualMachinesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -902,8 +913,7 @@ const deserializeAws_json1_0PutMaintenanceStartTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backupgateway#ConflictException": @@ -919,10 +929,12 @@ const deserializeAws_json1_0PutMaintenanceStartTimeCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -954,8 +966,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -968,10 +979,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1003,8 +1016,7 @@ const deserializeAws_json1_0TestHypervisorConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backupgateway#ConflictException": @@ -1020,10 +1032,12 @@ const deserializeAws_json1_0TestHypervisorConfigurationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1055,8 +1069,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -1069,10 +1082,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1104,8 +1119,7 @@ const deserializeAws_json1_0UpdateGatewayInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backupgateway#ConflictException": @@ -1121,10 +1135,12 @@ const deserializeAws_json1_0UpdateGatewayInformationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1156,8 +1172,7 @@ const deserializeAws_json1_0UpdateGatewaySoftwareNowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.backupgateway#InternalServerException": @@ -1170,10 +1185,12 @@ const deserializeAws_json1_0UpdateGatewaySoftwareNowCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1205,8 +1222,7 @@ const deserializeAws_json1_0UpdateHypervisorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.backupgateway#AccessDeniedException": @@ -1222,10 +1238,12 @@ const deserializeAws_json1_0UpdateHypervisorCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1845,7 +1863,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1871,6 +1889,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-backup/src/protocols/Aws_restJson1.ts b/clients/client-backup/src/protocols/Aws_restJson1.ts index 803b37c35762b..a4c919c84b02f 100644 --- a/clients/client-backup/src/protocols/Aws_restJson1.ts +++ b/clients/client-backup/src/protocols/Aws_restJson1.ts @@ -2424,8 +2424,7 @@ const deserializeAws_restJson1CreateBackupPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -2444,10 +2443,12 @@ const deserializeAws_restJson1CreateBackupPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2488,8 +2489,7 @@ const deserializeAws_restJson1CreateBackupSelectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -2508,10 +2508,12 @@ const deserializeAws_restJson1CreateBackupSelectionCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2552,8 +2554,7 @@ const deserializeAws_restJson1CreateBackupVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -2572,10 +2573,12 @@ const deserializeAws_restJson1CreateBackupVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2612,8 +2615,7 @@ const deserializeAws_restJson1CreateFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -2632,10 +2634,12 @@ const deserializeAws_restJson1CreateFrameworkCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2676,8 +2680,7 @@ const deserializeAws_restJson1CreateReportPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -2696,10 +2699,12 @@ const deserializeAws_restJson1CreateReportPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2744,8 +2749,7 @@ const deserializeAws_restJson1DeleteBackupPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -2764,10 +2768,12 @@ const deserializeAws_restJson1DeleteBackupPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2796,8 +2802,7 @@ const deserializeAws_restJson1DeleteBackupSelectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -2813,10 +2818,12 @@ const deserializeAws_restJson1DeleteBackupSelectionCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2845,8 +2852,7 @@ const deserializeAws_restJson1DeleteBackupVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -2865,10 +2871,12 @@ const deserializeAws_restJson1DeleteBackupVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2897,8 +2905,7 @@ const deserializeAws_restJson1DeleteBackupVaultAccessPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -2914,10 +2921,12 @@ const deserializeAws_restJson1DeleteBackupVaultAccessPolicyCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2946,8 +2955,7 @@ const deserializeAws_restJson1DeleteBackupVaultLockConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -2966,10 +2974,12 @@ const deserializeAws_restJson1DeleteBackupVaultLockConfigurationCommandError = a throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2998,8 +3008,7 @@ const deserializeAws_restJson1DeleteBackupVaultNotificationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3015,10 +3024,12 @@ const deserializeAws_restJson1DeleteBackupVaultNotificationsCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3047,8 +3058,7 @@ const deserializeAws_restJson1DeleteFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backup#ConflictException": @@ -3067,10 +3077,12 @@ const deserializeAws_restJson1DeleteFrameworkCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3099,8 +3111,7 @@ const deserializeAws_restJson1DeleteRecoveryPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3122,10 +3133,12 @@ const deserializeAws_restJson1DeleteRecoveryPointCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3154,8 +3167,7 @@ const deserializeAws_restJson1DeleteReportPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backup#ConflictException": @@ -3174,10 +3186,12 @@ const deserializeAws_restJson1DeleteReportPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3288,8 +3302,7 @@ const deserializeAws_restJson1DescribeBackupJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyFailureException": case "com.amazonaws.backup#DependencyFailureException": @@ -3308,10 +3321,12 @@ const deserializeAws_restJson1DescribeBackupJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3380,8 +3395,7 @@ const deserializeAws_restJson1DescribeBackupVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3397,10 +3411,12 @@ const deserializeAws_restJson1DescribeBackupVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3433,8 +3449,7 @@ const deserializeAws_restJson1DescribeCopyJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3450,10 +3465,12 @@ const deserializeAws_restJson1DescribeCopyJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3514,8 +3531,7 @@ const deserializeAws_restJson1DescribeFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3531,10 +3547,12 @@ const deserializeAws_restJson1DescribeFrameworkCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3571,8 +3589,7 @@ const deserializeAws_restJson1DescribeGlobalSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.backup#InvalidRequestException": @@ -3582,10 +3599,12 @@ const deserializeAws_restJson1DescribeGlobalSettingsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3626,8 +3645,7 @@ const deserializeAws_restJson1DescribeProtectedResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3643,10 +3661,12 @@ const deserializeAws_restJson1DescribeProtectedResourceCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3751,8 +3771,7 @@ const deserializeAws_restJson1DescribeRecoveryPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3768,10 +3787,12 @@ const deserializeAws_restJson1DescribeRecoveryPointCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3814,18 +3835,19 @@ const deserializeAws_restJson1DescribeRegionSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceUnavailableException": case "com.amazonaws.backup#ServiceUnavailableException": throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3858,8 +3880,7 @@ const deserializeAws_restJson1DescribeReportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "MissingParameterValueException": case "com.amazonaws.backup#MissingParameterValueException": @@ -3872,10 +3893,12 @@ const deserializeAws_restJson1DescribeReportJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3908,8 +3931,7 @@ const deserializeAws_restJson1DescribeReportPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -3925,10 +3947,12 @@ const deserializeAws_restJson1DescribeReportPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4009,8 +4033,7 @@ const deserializeAws_restJson1DescribeRestoreJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyFailureException": case "com.amazonaws.backup#DependencyFailureException": @@ -4029,10 +4052,12 @@ const deserializeAws_restJson1DescribeRestoreJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4061,8 +4086,7 @@ const deserializeAws_restJson1DisassociateRecoveryPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4084,10 +4108,12 @@ const deserializeAws_restJson1DisassociateRecoveryPointCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4120,8 +4146,7 @@ const deserializeAws_restJson1ExportBackupPlanTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4137,10 +4162,12 @@ const deserializeAws_restJson1ExportBackupPlanTemplateCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4208,8 +4235,7 @@ const deserializeAws_restJson1GetBackupPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4225,10 +4251,12 @@ const deserializeAws_restJson1GetBackupPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4261,8 +4289,7 @@ const deserializeAws_restJson1GetBackupPlanFromJSONCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4281,10 +4308,12 @@ const deserializeAws_restJson1GetBackupPlanFromJSONCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4317,8 +4346,7 @@ const deserializeAws_restJson1GetBackupPlanFromTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4334,10 +4362,12 @@ const deserializeAws_restJson1GetBackupPlanFromTemplateCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4386,8 +4416,7 @@ const deserializeAws_restJson1GetBackupSelectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4403,10 +4432,12 @@ const deserializeAws_restJson1GetBackupSelectionCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4447,8 +4478,7 @@ const deserializeAws_restJson1GetBackupVaultAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4464,10 +4494,12 @@ const deserializeAws_restJson1GetBackupVaultAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4512,8 +4544,7 @@ const deserializeAws_restJson1GetBackupVaultNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4529,10 +4560,12 @@ const deserializeAws_restJson1GetBackupVaultNotificationsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4573,8 +4606,7 @@ const deserializeAws_restJson1GetRecoveryPointRestoreMetadataCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4590,10 +4622,12 @@ const deserializeAws_restJson1GetRecoveryPointRestoreMetadataCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4626,18 +4660,19 @@ const deserializeAws_restJson1GetSupportedResourceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceUnavailableException": case "com.amazonaws.backup#ServiceUnavailableException": throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4674,8 +4709,7 @@ const deserializeAws_restJson1ListBackupJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4685,10 +4719,12 @@ const deserializeAws_restJson1ListBackupJobsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4725,8 +4761,7 @@ const deserializeAws_restJson1ListBackupPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4742,10 +4777,12 @@ const deserializeAws_restJson1ListBackupPlansCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4785,8 +4822,7 @@ const deserializeAws_restJson1ListBackupPlanTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4802,10 +4838,12 @@ const deserializeAws_restJson1ListBackupPlanTemplatesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4845,8 +4883,7 @@ const deserializeAws_restJson1ListBackupPlanVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4862,10 +4899,12 @@ const deserializeAws_restJson1ListBackupPlanVersionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4902,8 +4941,7 @@ const deserializeAws_restJson1ListBackupSelectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4919,10 +4957,12 @@ const deserializeAws_restJson1ListBackupSelectionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4959,8 +4999,7 @@ const deserializeAws_restJson1ListBackupVaultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -4976,10 +5015,12 @@ const deserializeAws_restJson1ListBackupVaultsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5016,8 +5057,7 @@ const deserializeAws_restJson1ListCopyJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5027,10 +5067,12 @@ const deserializeAws_restJson1ListCopyJobsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5067,8 +5109,7 @@ const deserializeAws_restJson1ListFrameworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5078,10 +5119,12 @@ const deserializeAws_restJson1ListFrameworksCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5118,8 +5161,7 @@ const deserializeAws_restJson1ListProtectedResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5129,10 +5171,12 @@ const deserializeAws_restJson1ListProtectedResourcesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5169,8 +5213,7 @@ const deserializeAws_restJson1ListRecoveryPointsByBackupVaultCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5186,10 +5229,12 @@ const deserializeAws_restJson1ListRecoveryPointsByBackupVaultCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5226,8 +5271,7 @@ const deserializeAws_restJson1ListRecoveryPointsByResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5243,10 +5287,12 @@ const deserializeAws_restJson1ListRecoveryPointsByResourceCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5283,8 +5329,7 @@ const deserializeAws_restJson1ListReportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5294,10 +5339,12 @@ const deserializeAws_restJson1ListReportJobsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5334,8 +5381,7 @@ const deserializeAws_restJson1ListReportPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5345,10 +5391,12 @@ const deserializeAws_restJson1ListReportPlansCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5385,8 +5433,7 @@ const deserializeAws_restJson1ListRestoreJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5402,10 +5449,12 @@ const deserializeAws_restJson1ListRestoreJobsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5442,8 +5491,7 @@ const deserializeAws_restJson1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5459,10 +5507,12 @@ const deserializeAws_restJson1ListTagsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5491,8 +5541,7 @@ const deserializeAws_restJson1PutBackupVaultAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5508,10 +5557,12 @@ const deserializeAws_restJson1PutBackupVaultAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5540,8 +5591,7 @@ const deserializeAws_restJson1PutBackupVaultLockConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5560,10 +5610,12 @@ const deserializeAws_restJson1PutBackupVaultLockConfigurationCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5592,8 +5644,7 @@ const deserializeAws_restJson1PutBackupVaultNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5609,10 +5660,12 @@ const deserializeAws_restJson1PutBackupVaultNotificationsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5653,8 +5706,7 @@ const deserializeAws_restJson1StartBackupJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5676,10 +5728,12 @@ const deserializeAws_restJson1StartBackupJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5716,8 +5770,7 @@ const deserializeAws_restJson1StartCopyJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5739,10 +5792,12 @@ const deserializeAws_restJson1StartCopyJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5775,8 +5830,7 @@ const deserializeAws_restJson1StartReportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5792,10 +5846,12 @@ const deserializeAws_restJson1StartReportJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5828,8 +5884,7 @@ const deserializeAws_restJson1StartRestoreJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5845,10 +5900,12 @@ const deserializeAws_restJson1StartRestoreJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5877,8 +5934,7 @@ const deserializeAws_restJson1StopBackupJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5897,10 +5953,12 @@ const deserializeAws_restJson1StopBackupJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5929,8 +5987,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5949,10 +6006,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5981,8 +6040,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -5998,10 +6056,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6053,8 +6113,7 @@ const deserializeAws_restJson1UpdateBackupPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -6070,10 +6129,12 @@ const deserializeAws_restJson1UpdateBackupPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6114,8 +6175,7 @@ const deserializeAws_restJson1UpdateFrameworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.backup#AlreadyExistsException": @@ -6140,10 +6200,12 @@ const deserializeAws_restJson1UpdateFrameworkCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6172,8 +6234,7 @@ const deserializeAws_restJson1UpdateGlobalSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -6189,10 +6250,12 @@ const deserializeAws_restJson1UpdateGlobalSettingsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6237,8 +6300,7 @@ const deserializeAws_restJson1UpdateRecoveryPointLifecycleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -6257,10 +6319,12 @@ const deserializeAws_restJson1UpdateRecoveryPointLifecycleCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6289,8 +6353,7 @@ const deserializeAws_restJson1UpdateRegionSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.backup#InvalidParameterValueException": @@ -6303,10 +6366,12 @@ const deserializeAws_restJson1UpdateRegionSettingsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6347,8 +6412,7 @@ const deserializeAws_restJson1UpdateReportPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.backup#ConflictException": @@ -6367,10 +6431,12 @@ const deserializeAws_restJson1UpdateReportPlanCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8065,7 +8131,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8091,6 +8157,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-batch/src/protocols/Aws_restJson1.ts b/clients/client-batch/src/protocols/Aws_restJson1.ts index fd065d86b77c2..b95405b609bef 100644 --- a/clients/client-batch/src/protocols/Aws_restJson1.ts +++ b/clients/client-batch/src/protocols/Aws_restJson1.ts @@ -912,8 +912,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -923,10 +922,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -963,8 +964,7 @@ const deserializeAws_restJson1CreateComputeEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -974,10 +974,12 @@ const deserializeAws_restJson1CreateComputeEnvironmentCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1014,8 +1016,7 @@ const deserializeAws_restJson1CreateJobQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1025,10 +1026,12 @@ const deserializeAws_restJson1CreateJobQueueCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1065,8 +1068,7 @@ const deserializeAws_restJson1CreateSchedulingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1076,10 +1078,12 @@ const deserializeAws_restJson1CreateSchedulingPolicyCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1108,8 +1112,7 @@ const deserializeAws_restJson1DeleteComputeEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1119,10 +1122,12 @@ const deserializeAws_restJson1DeleteComputeEnvironmentCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1151,8 +1156,7 @@ const deserializeAws_restJson1DeleteJobQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1162,10 +1166,12 @@ const deserializeAws_restJson1DeleteJobQueueCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1194,8 +1200,7 @@ const deserializeAws_restJson1DeleteSchedulingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1205,10 +1210,12 @@ const deserializeAws_restJson1DeleteSchedulingPolicyCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1237,8 +1244,7 @@ const deserializeAws_restJson1DeregisterJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1248,10 +1254,12 @@ const deserializeAws_restJson1DeregisterJobDefinitionCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1291,8 +1299,7 @@ const deserializeAws_restJson1DescribeComputeEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1302,10 +1309,12 @@ const deserializeAws_restJson1DescribeComputeEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1342,8 +1351,7 @@ const deserializeAws_restJson1DescribeJobDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1353,10 +1361,12 @@ const deserializeAws_restJson1DescribeJobDefinitionsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1393,8 +1403,7 @@ const deserializeAws_restJson1DescribeJobQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1404,10 +1413,12 @@ const deserializeAws_restJson1DescribeJobQueuesCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1440,8 +1451,7 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1451,10 +1461,12 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1487,8 +1499,7 @@ const deserializeAws_restJson1DescribeSchedulingPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1498,10 +1509,12 @@ const deserializeAws_restJson1DescribeSchedulingPoliciesCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1538,8 +1551,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1549,10 +1561,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1592,8 +1606,7 @@ const deserializeAws_restJson1ListSchedulingPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1603,10 +1616,12 @@ const deserializeAws_restJson1ListSchedulingPoliciesCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1639,8 +1654,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1650,10 +1664,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1710,7 @@ const deserializeAws_restJson1RegisterJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1705,10 +1720,12 @@ const deserializeAws_restJson1RegisterJobDefinitionCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1749,8 +1766,7 @@ const deserializeAws_restJson1SubmitJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1760,10 +1776,12 @@ const deserializeAws_restJson1SubmitJobCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1792,8 +1810,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1803,10 +1820,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1835,8 +1854,7 @@ const deserializeAws_restJson1TerminateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1846,10 +1864,12 @@ const deserializeAws_restJson1TerminateJobCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1878,8 +1898,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1889,10 +1908,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1929,8 +1950,7 @@ const deserializeAws_restJson1UpdateComputeEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1940,10 +1960,12 @@ const deserializeAws_restJson1UpdateComputeEnvironmentCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1980,8 +2002,7 @@ const deserializeAws_restJson1UpdateJobQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -1991,10 +2012,12 @@ const deserializeAws_restJson1UpdateJobQueueCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2023,8 +2046,7 @@ const deserializeAws_restJson1UpdateSchedulingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.batch#ClientException": @@ -2034,10 +2056,12 @@ const deserializeAws_restJson1UpdateSchedulingPolicyCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3922,7 +3946,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3948,6 +3972,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-billingconductor/src/protocols/Aws_restJson1.ts b/clients/client-billingconductor/src/protocols/Aws_restJson1.ts index f280261888003..df3b0d448e60f 100644 --- a/clients/client-billingconductor/src/protocols/Aws_restJson1.ts +++ b/clients/client-billingconductor/src/protocols/Aws_restJson1.ts @@ -1059,8 +1059,7 @@ const deserializeAws_restJson1AssociateAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1085,10 +1084,12 @@ const deserializeAws_restJson1AssociateAccountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1121,8 +1122,7 @@ const deserializeAws_restJson1AssociatePricingRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1147,10 +1147,12 @@ const deserializeAws_restJson1AssociatePricingRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1193,8 +1195,7 @@ const deserializeAws_restJson1BatchAssociateResourcesToCustomLineItemCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1219,10 +1220,12 @@ const deserializeAws_restJson1BatchAssociateResourcesToCustomLineItemCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1265,8 +1268,7 @@ const deserializeAws_restJson1BatchDisassociateResourcesFromCustomLineItemComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1288,10 +1290,12 @@ const deserializeAws_restJson1BatchDisassociateResourcesFromCustomLineItemComman throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1324,8 +1328,7 @@ const deserializeAws_restJson1CreateBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1347,10 +1350,12 @@ const deserializeAws_restJson1CreateBillingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1383,8 +1388,7 @@ const deserializeAws_restJson1CreateCustomLineItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1406,10 +1410,12 @@ const deserializeAws_restJson1CreateCustomLineItemCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1442,8 +1448,7 @@ const deserializeAws_restJson1CreatePricingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1468,10 +1473,12 @@ const deserializeAws_restJson1CreatePricingPlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1504,8 +1511,7 @@ const deserializeAws_restJson1CreatePricingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1527,10 +1533,12 @@ const deserializeAws_restJson1CreatePricingRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1563,8 +1571,7 @@ const deserializeAws_restJson1DeleteBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1580,10 +1587,12 @@ const deserializeAws_restJson1DeleteBillingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1616,8 +1625,7 @@ const deserializeAws_restJson1DeleteCustomLineItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1636,10 +1644,12 @@ const deserializeAws_restJson1DeleteCustomLineItemCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1672,8 +1682,7 @@ const deserializeAws_restJson1DeletePricingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1692,10 +1701,12 @@ const deserializeAws_restJson1DeletePricingPlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1728,8 +1739,7 @@ const deserializeAws_restJson1DeletePricingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1748,10 +1758,12 @@ const deserializeAws_restJson1DeletePricingRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1784,8 +1796,7 @@ const deserializeAws_restJson1DisassociateAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1807,10 +1818,12 @@ const deserializeAws_restJson1DisassociateAccountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1843,8 +1856,7 @@ const deserializeAws_restJson1DisassociatePricingRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1866,10 +1878,12 @@ const deserializeAws_restJson1DisassociatePricingRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1906,8 +1920,7 @@ const deserializeAws_restJson1ListAccountAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1926,10 +1939,12 @@ const deserializeAws_restJson1ListAccountAssociationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1969,8 +1984,7 @@ const deserializeAws_restJson1ListBillingGroupCostReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -1989,10 +2003,12 @@ const deserializeAws_restJson1ListBillingGroupCostReportsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2029,8 +2045,7 @@ const deserializeAws_restJson1ListBillingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2049,10 +2064,12 @@ const deserializeAws_restJson1ListBillingGroupsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2089,8 +2106,7 @@ const deserializeAws_restJson1ListCustomLineItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2109,10 +2125,12 @@ const deserializeAws_restJson1ListCustomLineItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2153,8 +2171,7 @@ const deserializeAws_restJson1ListPricingPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2170,10 +2187,12 @@ const deserializeAws_restJson1ListPricingPlansCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2218,8 +2237,7 @@ const deserializeAws_restJson1ListPricingPlansAssociatedWithPricingRuleCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2238,10 +2256,12 @@ const deserializeAws_restJson1ListPricingPlansAssociatedWithPricingRuleCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2282,8 +2302,7 @@ const deserializeAws_restJson1ListPricingRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2299,10 +2318,12 @@ const deserializeAws_restJson1ListPricingRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2347,8 +2368,7 @@ const deserializeAws_restJson1ListPricingRulesAssociatedToPricingPlanCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2367,10 +2387,12 @@ const deserializeAws_restJson1ListPricingRulesAssociatedToPricingPlanCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2414,8 +2436,7 @@ const deserializeAws_restJson1ListResourcesAssociatedToCustomLineItemCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2434,10 +2455,12 @@ const deserializeAws_restJson1ListResourcesAssociatedToCustomLineItemCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2470,8 +2493,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2490,10 +2512,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2522,8 +2546,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2542,10 +2565,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2574,8 +2599,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2594,10 +2618,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2662,8 +2688,7 @@ const deserializeAws_restJson1UpdateBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2685,10 +2710,12 @@ const deserializeAws_restJson1UpdateBillingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2745,8 +2772,7 @@ const deserializeAws_restJson1UpdateCustomLineItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2765,10 +2791,12 @@ const deserializeAws_restJson1UpdateCustomLineItemCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2817,8 +2845,7 @@ const deserializeAws_restJson1UpdatePricingPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2840,10 +2867,12 @@ const deserializeAws_restJson1UpdatePricingPlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2908,8 +2937,7 @@ const deserializeAws_restJson1UpdatePricingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.billingconductor#AccessDeniedException": @@ -2931,10 +2959,12 @@ const deserializeAws_restJson1UpdatePricingRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3810,7 +3840,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3836,6 +3866,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-braket/src/protocols/Aws_restJson1.ts b/clients/client-braket/src/protocols/Aws_restJson1.ts index da426647961ed..8ce91dc8b55a6 100644 --- a/clients/client-braket/src/protocols/Aws_restJson1.ts +++ b/clients/client-braket/src/protocols/Aws_restJson1.ts @@ -514,8 +514,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -537,10 +536,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -577,8 +578,7 @@ const deserializeAws_restJson1CancelQuantumTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -600,10 +600,12 @@ const deserializeAws_restJson1CancelQuantumTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -636,8 +638,7 @@ const deserializeAws_restJson1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -662,10 +663,12 @@ const deserializeAws_restJson1CreateJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -698,8 +701,7 @@ const deserializeAws_restJson1CreateQuantumTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -724,10 +726,12 @@ const deserializeAws_restJson1CreateQuantumTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -780,8 +784,7 @@ const deserializeAws_restJson1GetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -800,10 +803,12 @@ const deserializeAws_restJson1GetDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +916,7 @@ const deserializeAws_restJson1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -931,10 +935,12 @@ const deserializeAws_restJson1GetJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1011,8 +1017,7 @@ const deserializeAws_restJson1GetQuantumTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -1031,10 +1036,12 @@ const deserializeAws_restJson1GetQuantumTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1067,8 +1074,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.braket#InternalServiceException": @@ -1081,10 +1087,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1121,8 +1129,7 @@ const deserializeAws_restJson1SearchDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -1138,10 +1145,12 @@ const deserializeAws_restJson1SearchDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1178,8 +1187,7 @@ const deserializeAws_restJson1SearchJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -1195,10 +1203,12 @@ const deserializeAws_restJson1SearchJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1235,8 +1245,7 @@ const deserializeAws_restJson1SearchQuantumTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.braket#AccessDeniedException": @@ -1252,10 +1261,12 @@ const deserializeAws_restJson1SearchQuantumTasksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1284,8 +1295,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.braket#InternalServiceException": @@ -1298,10 +1308,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1330,8 +1342,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.braket#InternalServiceException": @@ -1344,10 +1355,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1974,7 +1987,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2000,6 +2013,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-budgets/src/protocols/Aws_json1_1.ts b/clients/client-budgets/src/protocols/Aws_json1_1.ts index 396cdac59c9ea..b42dc549d3d42 100644 --- a/clients/client-budgets/src/protocols/Aws_json1_1.ts +++ b/clients/client-budgets/src/protocols/Aws_json1_1.ts @@ -474,8 +474,7 @@ const deserializeAws_json1_1CreateBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -497,10 +496,12 @@ const deserializeAws_json1_1CreateBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -532,8 +533,7 @@ const deserializeAws_json1_1CreateBudgetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -558,10 +558,12 @@ const deserializeAws_json1_1CreateBudgetActionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -593,8 +595,7 @@ const deserializeAws_json1_1CreateNotificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -619,10 +620,12 @@ const deserializeAws_json1_1CreateNotificationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -654,8 +657,7 @@ const deserializeAws_json1_1CreateSubscriberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -680,10 +682,12 @@ const deserializeAws_json1_1CreateSubscriberCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -715,8 +719,7 @@ const deserializeAws_json1_1DeleteBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -735,10 +738,12 @@ const deserializeAws_json1_1DeleteBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -770,8 +775,7 @@ const deserializeAws_json1_1DeleteBudgetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -793,10 +797,12 @@ const deserializeAws_json1_1DeleteBudgetActionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -828,8 +834,7 @@ const deserializeAws_json1_1DeleteNotificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -848,10 +853,12 @@ const deserializeAws_json1_1DeleteNotificationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -883,8 +890,7 @@ const deserializeAws_json1_1DeleteSubscriberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -903,10 +909,12 @@ const deserializeAws_json1_1DeleteSubscriberCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -938,8 +946,7 @@ const deserializeAws_json1_1DescribeBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -958,10 +965,12 @@ const deserializeAws_json1_1DescribeBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -993,8 +1002,7 @@ const deserializeAws_json1_1DescribeBudgetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1013,10 +1021,12 @@ const deserializeAws_json1_1DescribeBudgetActionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1048,8 +1058,7 @@ const deserializeAws_json1_1DescribeBudgetActionHistoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1071,10 +1080,12 @@ const deserializeAws_json1_1DescribeBudgetActionHistoriesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1106,8 +1117,7 @@ const deserializeAws_json1_1DescribeBudgetActionsForAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1126,10 +1136,12 @@ const deserializeAws_json1_1DescribeBudgetActionsForAccountCommandError = async throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1161,8 +1173,7 @@ const deserializeAws_json1_1DescribeBudgetActionsForBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1184,10 +1195,12 @@ const deserializeAws_json1_1DescribeBudgetActionsForBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1219,8 +1232,7 @@ const deserializeAws_json1_1DescribeBudgetNotificationsForAccountCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1245,10 +1257,12 @@ const deserializeAws_json1_1DescribeBudgetNotificationsForAccountCommandError = throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1280,8 +1294,7 @@ const deserializeAws_json1_1DescribeBudgetPerformanceHistoryCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1306,10 +1319,12 @@ const deserializeAws_json1_1DescribeBudgetPerformanceHistoryCommandError = async throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1341,8 +1356,7 @@ const deserializeAws_json1_1DescribeBudgetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1367,10 +1381,12 @@ const deserializeAws_json1_1DescribeBudgetsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1402,8 +1418,7 @@ const deserializeAws_json1_1DescribeNotificationsForBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1428,10 +1443,12 @@ const deserializeAws_json1_1DescribeNotificationsForBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1463,8 +1480,7 @@ const deserializeAws_json1_1DescribeSubscribersForNotificationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1489,10 +1505,12 @@ const deserializeAws_json1_1DescribeSubscribersForNotificationCommandError = asy throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1524,8 +1542,7 @@ const deserializeAws_json1_1ExecuteBudgetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1547,10 +1564,12 @@ const deserializeAws_json1_1ExecuteBudgetActionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1601,7 @@ const deserializeAws_json1_1UpdateBudgetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1602,10 +1620,12 @@ const deserializeAws_json1_1UpdateBudgetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1637,8 +1657,7 @@ const deserializeAws_json1_1UpdateBudgetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1660,10 +1679,12 @@ const deserializeAws_json1_1UpdateBudgetActionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1695,8 +1716,7 @@ const deserializeAws_json1_1UpdateNotificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1718,10 +1738,12 @@ const deserializeAws_json1_1UpdateNotificationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1753,8 +1775,7 @@ const deserializeAws_json1_1UpdateSubscriberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.budgets#AccessDeniedException": @@ -1776,10 +1797,12 @@ const deserializeAws_json1_1UpdateSubscriberCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3362,7 +3385,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3388,6 +3411,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-chime-sdk-identity/src/protocols/Aws_restJson1.ts b/clients/client-chime-sdk-identity/src/protocols/Aws_restJson1.ts index 26b05b14171f9..121efb916ef6a 100644 --- a/clients/client-chime-sdk-identity/src/protocols/Aws_restJson1.ts +++ b/clients/client-chime-sdk-identity/src/protocols/Aws_restJson1.ts @@ -945,8 +945,7 @@ const deserializeAws_restJson1CreateAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -974,10 +973,12 @@ const deserializeAws_restJson1CreateAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1014,8 +1015,7 @@ const deserializeAws_restJson1CreateAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1043,10 +1043,12 @@ const deserializeAws_restJson1CreateAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1079,8 +1081,7 @@ const deserializeAws_restJson1CreateAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1108,10 +1109,12 @@ const deserializeAws_restJson1CreateAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1140,8 +1143,7 @@ const deserializeAws_restJson1DeleteAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1166,10 +1168,12 @@ const deserializeAws_restJson1DeleteAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1198,8 +1202,7 @@ const deserializeAws_restJson1DeleteAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1227,10 +1230,12 @@ const deserializeAws_restJson1DeleteAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1259,8 +1264,7 @@ const deserializeAws_restJson1DeleteAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1288,10 +1292,12 @@ const deserializeAws_restJson1DeleteAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1320,8 +1326,7 @@ const deserializeAws_restJson1DeregisterAppInstanceUserEndpointCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1343,10 +1348,12 @@ const deserializeAws_restJson1DeregisterAppInstanceUserEndpointCommandError = as throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1379,8 +1386,7 @@ const deserializeAws_restJson1DescribeAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1402,10 +1408,12 @@ const deserializeAws_restJson1DescribeAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1438,8 +1446,7 @@ const deserializeAws_restJson1DescribeAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1461,10 +1468,12 @@ const deserializeAws_restJson1DescribeAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1497,8 +1506,7 @@ const deserializeAws_restJson1DescribeAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1520,10 +1528,12 @@ const deserializeAws_restJson1DescribeAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1559,8 +1569,7 @@ const deserializeAws_restJson1DescribeAppInstanceUserEndpointCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1582,10 +1591,12 @@ const deserializeAws_restJson1DescribeAppInstanceUserEndpointCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1627,8 +1638,7 @@ const deserializeAws_restJson1GetAppInstanceRetentionSettingsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1650,10 +1660,12 @@ const deserializeAws_restJson1GetAppInstanceRetentionSettingsCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1706,7 @@ const deserializeAws_restJson1ListAppInstanceAdminsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1720,10 +1731,12 @@ const deserializeAws_restJson1ListAppInstanceAdminsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1760,8 +1773,7 @@ const deserializeAws_restJson1ListAppInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1783,10 +1795,12 @@ const deserializeAws_restJson1ListAppInstancesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1840,7 @@ const deserializeAws_restJson1ListAppInstanceUserEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1849,10 +1862,12 @@ const deserializeAws_restJson1ListAppInstanceUserEndpointsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1893,8 +1908,7 @@ const deserializeAws_restJson1ListAppInstanceUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1916,10 +1930,12 @@ const deserializeAws_restJson1ListAppInstanceUsersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1952,8 +1968,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -1975,10 +1990,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2020,8 +2037,7 @@ const deserializeAws_restJson1PutAppInstanceRetentionSettingsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2043,10 +2059,12 @@ const deserializeAws_restJson1PutAppInstanceRetentionSettingsCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2083,8 +2101,7 @@ const deserializeAws_restJson1RegisterAppInstanceUserEndpointCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2112,10 +2129,12 @@ const deserializeAws_restJson1RegisterAppInstanceUserEndpointCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2144,8 +2163,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2170,10 +2188,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2202,8 +2222,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2225,10 +2244,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2261,8 +2282,7 @@ const deserializeAws_restJson1UpdateAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2287,10 +2307,12 @@ const deserializeAws_restJson1UpdateAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2323,8 +2345,7 @@ const deserializeAws_restJson1UpdateAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2352,10 +2373,12 @@ const deserializeAws_restJson1UpdateAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2392,8 +2415,7 @@ const deserializeAws_restJson1UpdateAppInstanceUserEndpointCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkidentity#BadRequestException": @@ -2418,10 +2440,12 @@ const deserializeAws_restJson1UpdateAppInstanceUserEndpointCommandError = async throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2919,7 +2943,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2945,6 +2969,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-chime-sdk-media-pipelines/src/protocols/Aws_restJson1.ts b/clients/client-chime-sdk-media-pipelines/src/protocols/Aws_restJson1.ts index 32805b27cdb9e..55c097abd37ba 100644 --- a/clients/client-chime-sdk-media-pipelines/src/protocols/Aws_restJson1.ts +++ b/clients/client-chime-sdk-media-pipelines/src/protocols/Aws_restJson1.ts @@ -292,8 +292,7 @@ const deserializeAws_restJson1CreateMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -318,10 +317,12 @@ const deserializeAws_restJson1CreateMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -350,8 +351,7 @@ const deserializeAws_restJson1DeleteMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -376,10 +376,12 @@ const deserializeAws_restJson1DeleteMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -412,8 +414,7 @@ const deserializeAws_restJson1GetMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -438,10 +439,12 @@ const deserializeAws_restJson1GetMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -481,8 +484,7 @@ const deserializeAws_restJson1ListMediaCapturePipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -507,10 +509,12 @@ const deserializeAws_restJson1ListMediaCapturePipelinesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -543,8 +547,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -569,10 +572,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -601,8 +606,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -627,10 +631,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -659,8 +665,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmediapipelines#BadRequestException": @@ -685,10 +690,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1215,7 +1222,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1241,6 +1248,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-chime-sdk-meetings/src/protocols/Aws_restJson1.ts b/clients/client-chime-sdk-meetings/src/protocols/Aws_restJson1.ts index a3467184a5017..96391b0c82fcd 100644 --- a/clients/client-chime-sdk-meetings/src/protocols/Aws_restJson1.ts +++ b/clients/client-chime-sdk-meetings/src/protocols/Aws_restJson1.ts @@ -611,8 +611,7 @@ const deserializeAws_restJson1BatchCreateAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -643,10 +642,12 @@ const deserializeAws_restJson1BatchCreateAttendeeCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -675,8 +676,7 @@ const deserializeAws_restJson1BatchUpdateAttendeeCapabilitiesExceptCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -698,10 +698,12 @@ const deserializeAws_restJson1BatchUpdateAttendeeCapabilitiesExceptCommandError throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -734,8 +736,7 @@ const deserializeAws_restJson1CreateAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -766,10 +767,12 @@ const deserializeAws_restJson1CreateAttendeeCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -802,8 +805,7 @@ const deserializeAws_restJson1CreateMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -828,10 +830,12 @@ const deserializeAws_restJson1CreateMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -872,8 +876,7 @@ const deserializeAws_restJson1CreateMeetingWithAttendeesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -898,10 +901,12 @@ const deserializeAws_restJson1CreateMeetingWithAttendeesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -930,8 +935,7 @@ const deserializeAws_restJson1DeleteAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -956,10 +960,12 @@ const deserializeAws_restJson1DeleteAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -988,8 +994,7 @@ const deserializeAws_restJson1DeleteMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1014,10 +1019,12 @@ const deserializeAws_restJson1DeleteMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1050,8 +1057,7 @@ const deserializeAws_restJson1GetAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1076,10 +1082,12 @@ const deserializeAws_restJson1GetAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1112,8 +1120,7 @@ const deserializeAws_restJson1GetMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1138,10 +1145,12 @@ const deserializeAws_restJson1GetMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1178,8 +1187,7 @@ const deserializeAws_restJson1ListAttendeesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1204,10 +1212,12 @@ const deserializeAws_restJson1ListAttendeesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1236,8 +1246,7 @@ const deserializeAws_restJson1StartMeetingTranscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1268,10 +1277,12 @@ const deserializeAws_restJson1StartMeetingTranscriptionCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1311,7 @@ const deserializeAws_restJson1StopMeetingTranscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1329,10 +1339,12 @@ const deserializeAws_restJson1StopMeetingTranscriptionCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1365,8 +1377,7 @@ const deserializeAws_restJson1UpdateAttendeeCapabilitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmeetings#BadRequestException": @@ -1388,10 +1399,12 @@ const deserializeAws_restJson1UpdateAttendeeCapabilitiesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1930,7 +1943,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1956,6 +1969,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-chime-sdk-messaging/src/protocols/Aws_restJson1.ts b/clients/client-chime-sdk-messaging/src/protocols/Aws_restJson1.ts index 5a4c9b34bc1fd..86944a3cb9444 100644 --- a/clients/client-chime-sdk-messaging/src/protocols/Aws_restJson1.ts +++ b/clients/client-chime-sdk-messaging/src/protocols/Aws_restJson1.ts @@ -1867,8 +1867,7 @@ const deserializeAws_restJson1AssociateChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -1896,10 +1895,12 @@ const deserializeAws_restJson1AssociateChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1939,8 +1940,7 @@ const deserializeAws_restJson1BatchCreateChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -1962,10 +1962,12 @@ const deserializeAws_restJson1BatchCreateChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2002,8 +2004,7 @@ const deserializeAws_restJson1ChannelFlowCallbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2028,10 +2029,12 @@ const deserializeAws_restJson1ChannelFlowCallbackCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2064,8 +2067,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2093,10 +2095,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2137,7 @@ const deserializeAws_restJson1CreateChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2162,10 +2165,12 @@ const deserializeAws_restJson1CreateChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2198,8 +2203,7 @@ const deserializeAws_restJson1CreateChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2227,10 +2231,12 @@ const deserializeAws_restJson1CreateChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2267,8 +2273,7 @@ const deserializeAws_restJson1CreateChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2296,10 +2301,12 @@ const deserializeAws_restJson1CreateChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2336,8 +2343,7 @@ const deserializeAws_restJson1CreateChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2365,10 +2371,12 @@ const deserializeAws_restJson1CreateChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2397,8 +2405,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2420,10 +2427,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2452,8 +2461,7 @@ const deserializeAws_restJson1DeleteChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2475,10 +2483,12 @@ const deserializeAws_restJson1DeleteChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2507,8 +2517,7 @@ const deserializeAws_restJson1DeleteChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2533,10 +2542,12 @@ const deserializeAws_restJson1DeleteChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2565,8 +2576,7 @@ const deserializeAws_restJson1DeleteChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2591,10 +2601,12 @@ const deserializeAws_restJson1DeleteChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2623,8 +2635,7 @@ const deserializeAws_restJson1DeleteChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2646,10 +2657,12 @@ const deserializeAws_restJson1DeleteChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2678,8 +2691,7 @@ const deserializeAws_restJson1DeleteChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2701,10 +2713,12 @@ const deserializeAws_restJson1DeleteChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2737,8 +2751,7 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2760,10 +2773,12 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2796,8 +2811,7 @@ const deserializeAws_restJson1DescribeChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2822,10 +2836,12 @@ const deserializeAws_restJson1DescribeChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2858,8 +2874,7 @@ const deserializeAws_restJson1DescribeChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2881,10 +2896,12 @@ const deserializeAws_restJson1DescribeChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2917,8 +2934,7 @@ const deserializeAws_restJson1DescribeChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -2943,10 +2959,12 @@ const deserializeAws_restJson1DescribeChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2982,8 +3000,7 @@ const deserializeAws_restJson1DescribeChannelMembershipForAppInstanceUserCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3005,10 +3022,12 @@ const deserializeAws_restJson1DescribeChannelMembershipForAppInstanceUserCommand throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3041,8 +3060,7 @@ const deserializeAws_restJson1DescribeChannelModeratedByAppInstanceUserCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3064,10 +3082,12 @@ const deserializeAws_restJson1DescribeChannelModeratedByAppInstanceUserCommandEr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3100,8 +3120,7 @@ const deserializeAws_restJson1DescribeChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3126,10 +3145,12 @@ const deserializeAws_restJson1DescribeChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3158,8 +3179,7 @@ const deserializeAws_restJson1DisassociateChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3187,10 +3207,12 @@ const deserializeAws_restJson1DisassociateChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3231,8 +3253,7 @@ const deserializeAws_restJson1GetChannelMembershipPreferencesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3254,10 +3275,12 @@ const deserializeAws_restJson1GetChannelMembershipPreferencesCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3290,8 +3313,7 @@ const deserializeAws_restJson1GetChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3316,10 +3338,12 @@ const deserializeAws_restJson1GetChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3352,8 +3376,7 @@ const deserializeAws_restJson1GetChannelMessageStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3375,10 +3398,12 @@ const deserializeAws_restJson1GetChannelMessageStatusCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3411,8 +3436,7 @@ const deserializeAws_restJson1GetMessagingSessionEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.chimesdkmessaging#ForbiddenException": @@ -3431,10 +3455,12 @@ const deserializeAws_restJson1GetMessagingSessionEndpointCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3475,8 +3501,7 @@ const deserializeAws_restJson1ListChannelBansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3498,10 +3523,12 @@ const deserializeAws_restJson1ListChannelBansCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3538,8 +3565,7 @@ const deserializeAws_restJson1ListChannelFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3561,10 +3587,12 @@ const deserializeAws_restJson1ListChannelFlowsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3608,8 +3636,7 @@ const deserializeAws_restJson1ListChannelMembershipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3631,10 +3658,12 @@ const deserializeAws_restJson1ListChannelMembershipsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3674,8 +3703,7 @@ const deserializeAws_restJson1ListChannelMembershipsForAppInstanceUserCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3697,10 +3725,12 @@ const deserializeAws_restJson1ListChannelMembershipsForAppInstanceUserCommandErr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3741,8 +3771,7 @@ const deserializeAws_restJson1ListChannelMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3764,10 +3793,12 @@ const deserializeAws_restJson1ListChannelMessagesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3808,8 +3839,7 @@ const deserializeAws_restJson1ListChannelModeratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3831,10 +3861,12 @@ const deserializeAws_restJson1ListChannelModeratorsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3871,8 +3903,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3894,10 +3925,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3934,8 +3967,7 @@ const deserializeAws_restJson1ListChannelsAssociatedWithChannelFlowCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -3957,10 +3989,12 @@ const deserializeAws_restJson1ListChannelsAssociatedWithChannelFlowCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3997,8 +4031,7 @@ const deserializeAws_restJson1ListChannelsModeratedByAppInstanceUserCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4020,10 +4053,12 @@ const deserializeAws_restJson1ListChannelsModeratedByAppInstanceUserCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4056,8 +4091,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4079,10 +4113,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4123,8 +4159,7 @@ const deserializeAws_restJson1PutChannelMembershipPreferencesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4149,10 +4184,12 @@ const deserializeAws_restJson1PutChannelMembershipPreferencesCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4189,8 +4226,7 @@ const deserializeAws_restJson1RedactChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4215,10 +4251,12 @@ const deserializeAws_restJson1RedactChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4255,8 +4293,7 @@ const deserializeAws_restJson1SearchChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4278,10 +4315,12 @@ const deserializeAws_restJson1SearchChannelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4322,8 +4361,7 @@ const deserializeAws_restJson1SendChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4348,10 +4386,12 @@ const deserializeAws_restJson1SendChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4380,8 +4420,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4406,10 +4445,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4438,8 +4479,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4461,10 +4501,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4497,8 +4539,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4523,10 +4564,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4559,8 +4602,7 @@ const deserializeAws_restJson1UpdateChannelFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4585,10 +4627,12 @@ const deserializeAws_restJson1UpdateChannelFlowCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4629,8 +4673,7 @@ const deserializeAws_restJson1UpdateChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4655,10 +4698,12 @@ const deserializeAws_restJson1UpdateChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4691,8 +4736,7 @@ const deserializeAws_restJson1UpdateChannelReadMarkerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chimesdkmessaging#BadRequestException": @@ -4717,10 +4761,12 @@ const deserializeAws_restJson1UpdateChannelReadMarkerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5767,7 +5813,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5793,6 +5839,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-chime/src/protocols/Aws_restJson1.ts b/clients/client-chime/src/protocols/Aws_restJson1.ts index e898148e02d66..97ea0db4e880c 100644 --- a/clients/client-chime/src/protocols/Aws_restJson1.ts +++ b/clients/client-chime/src/protocols/Aws_restJson1.ts @@ -7723,8 +7723,7 @@ const deserializeAws_restJson1AssociatePhoneNumbersWithVoiceConnectorCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -7752,10 +7751,12 @@ const deserializeAws_restJson1AssociatePhoneNumbersWithVoiceConnectorCommandErro throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7788,8 +7789,7 @@ const deserializeAws_restJson1AssociatePhoneNumbersWithVoiceConnectorGroupComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -7817,10 +7817,12 @@ const deserializeAws_restJson1AssociatePhoneNumbersWithVoiceConnectorGroupComman throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7849,8 +7851,7 @@ const deserializeAws_restJson1AssociatePhoneNumberWithUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -7878,10 +7879,12 @@ const deserializeAws_restJson1AssociatePhoneNumberWithUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7910,8 +7913,7 @@ const deserializeAws_restJson1AssociateSigninDelegateGroupsWithAccountCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -7936,10 +7938,12 @@ const deserializeAws_restJson1AssociateSigninDelegateGroupsWithAccountCommandErr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7976,8 +7980,7 @@ const deserializeAws_restJson1BatchCreateAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8005,10 +8008,12 @@ const deserializeAws_restJson1BatchCreateAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8048,8 +8053,7 @@ const deserializeAws_restJson1BatchCreateChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8071,10 +8075,12 @@ const deserializeAws_restJson1BatchCreateChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8107,8 +8113,7 @@ const deserializeAws_restJson1BatchCreateRoomMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8133,10 +8138,12 @@ const deserializeAws_restJson1BatchCreateRoomMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8169,8 +8176,7 @@ const deserializeAws_restJson1BatchDeletePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8195,10 +8201,12 @@ const deserializeAws_restJson1BatchDeletePhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8231,8 +8239,7 @@ const deserializeAws_restJson1BatchSuspendUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8257,10 +8264,12 @@ const deserializeAws_restJson1BatchSuspendUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8293,8 +8302,7 @@ const deserializeAws_restJson1BatchUnsuspendUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8319,10 +8327,12 @@ const deserializeAws_restJson1BatchUnsuspendUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8355,8 +8365,7 @@ const deserializeAws_restJson1BatchUpdatePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8381,10 +8390,12 @@ const deserializeAws_restJson1BatchUpdatePhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8417,8 +8428,7 @@ const deserializeAws_restJson1BatchUpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8443,10 +8453,12 @@ const deserializeAws_restJson1BatchUpdateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8479,8 +8491,7 @@ const deserializeAws_restJson1CreateAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8505,10 +8516,12 @@ const deserializeAws_restJson1CreateAccountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8541,8 +8554,7 @@ const deserializeAws_restJson1CreateAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8570,10 +8582,12 @@ const deserializeAws_restJson1CreateAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8610,8 +8624,7 @@ const deserializeAws_restJson1CreateAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8639,10 +8652,12 @@ const deserializeAws_restJson1CreateAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8675,8 +8690,7 @@ const deserializeAws_restJson1CreateAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8704,10 +8718,12 @@ const deserializeAws_restJson1CreateAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8740,8 +8756,7 @@ const deserializeAws_restJson1CreateAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8769,10 +8784,12 @@ const deserializeAws_restJson1CreateAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8805,8 +8822,7 @@ const deserializeAws_restJson1CreateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8834,10 +8850,12 @@ const deserializeAws_restJson1CreateBotCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8870,8 +8888,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8899,10 +8916,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8939,8 +8958,7 @@ const deserializeAws_restJson1CreateChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -8968,10 +8986,12 @@ const deserializeAws_restJson1CreateChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9008,8 +9028,7 @@ const deserializeAws_restJson1CreateChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9037,10 +9056,12 @@ const deserializeAws_restJson1CreateChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9077,8 +9098,7 @@ const deserializeAws_restJson1CreateChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9106,10 +9126,12 @@ const deserializeAws_restJson1CreateChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9142,8 +9164,7 @@ const deserializeAws_restJson1CreateMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9168,10 +9189,12 @@ const deserializeAws_restJson1CreateMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9204,8 +9227,7 @@ const deserializeAws_restJson1CreateMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9230,10 +9252,12 @@ const deserializeAws_restJson1CreateMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9266,8 +9290,7 @@ const deserializeAws_restJson1CreateMeetingDialOutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9295,10 +9318,12 @@ const deserializeAws_restJson1CreateMeetingDialOutCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9339,8 +9364,7 @@ const deserializeAws_restJson1CreateMeetingWithAttendeesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9365,10 +9389,12 @@ const deserializeAws_restJson1CreateMeetingWithAttendeesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9401,8 +9427,7 @@ const deserializeAws_restJson1CreatePhoneNumberOrderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9430,10 +9455,12 @@ const deserializeAws_restJson1CreatePhoneNumberOrderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9466,8 +9493,7 @@ const deserializeAws_restJson1CreateProxySessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9492,10 +9518,12 @@ const deserializeAws_restJson1CreateProxySessionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9528,8 +9556,7 @@ const deserializeAws_restJson1CreateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9557,10 +9584,12 @@ const deserializeAws_restJson1CreateRoomCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9593,8 +9622,7 @@ const deserializeAws_restJson1CreateRoomMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9625,10 +9653,12 @@ const deserializeAws_restJson1CreateRoomMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9661,8 +9691,7 @@ const deserializeAws_restJson1CreateSipMediaApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9693,10 +9722,12 @@ const deserializeAws_restJson1CreateSipMediaApplicationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9732,8 +9763,7 @@ const deserializeAws_restJson1CreateSipMediaApplicationCallCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9761,10 +9791,12 @@ const deserializeAws_restJson1CreateSipMediaApplicationCallCommandError = async throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9797,8 +9829,7 @@ const deserializeAws_restJson1CreateSipRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9829,10 +9860,12 @@ const deserializeAws_restJson1CreateSipRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9865,8 +9898,7 @@ const deserializeAws_restJson1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -9894,10 +9926,12 @@ const deserializeAws_restJson1CreateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9930,8 +9964,7 @@ const deserializeAws_restJson1CreateVoiceConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -9959,10 +9992,12 @@ const deserializeAws_restJson1CreateVoiceConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9995,8 +10030,7 @@ const deserializeAws_restJson1CreateVoiceConnectorGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -10024,10 +10058,12 @@ const deserializeAws_restJson1CreateVoiceConnectorGroupCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10056,8 +10092,7 @@ const deserializeAws_restJson1DeleteAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10085,10 +10120,12 @@ const deserializeAws_restJson1DeleteAccountCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10117,8 +10154,7 @@ const deserializeAws_restJson1DeleteAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10140,10 +10176,12 @@ const deserializeAws_restJson1DeleteAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10172,8 +10210,7 @@ const deserializeAws_restJson1DeleteAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10198,10 +10235,12 @@ const deserializeAws_restJson1DeleteAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10230,8 +10269,7 @@ const deserializeAws_restJson1DeleteAppInstanceStreamingConfigurationsCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10256,10 +10294,12 @@ const deserializeAws_restJson1DeleteAppInstanceStreamingConfigurationsCommandErr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10288,8 +10328,7 @@ const deserializeAws_restJson1DeleteAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10311,10 +10350,12 @@ const deserializeAws_restJson1DeleteAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10343,8 +10384,7 @@ const deserializeAws_restJson1DeleteAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10369,10 +10409,12 @@ const deserializeAws_restJson1DeleteAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10401,8 +10443,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10424,10 +10465,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10456,8 +10499,7 @@ const deserializeAws_restJson1DeleteChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10479,10 +10521,12 @@ const deserializeAws_restJson1DeleteChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10511,8 +10555,7 @@ const deserializeAws_restJson1DeleteChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10537,10 +10580,12 @@ const deserializeAws_restJson1DeleteChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10569,8 +10614,7 @@ const deserializeAws_restJson1DeleteChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10592,10 +10636,12 @@ const deserializeAws_restJson1DeleteChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10624,8 +10670,7 @@ const deserializeAws_restJson1DeleteChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10647,10 +10692,12 @@ const deserializeAws_restJson1DeleteChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10679,8 +10726,7 @@ const deserializeAws_restJson1DeleteEventsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10702,10 +10748,12 @@ const deserializeAws_restJson1DeleteEventsConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10734,8 +10782,7 @@ const deserializeAws_restJson1DeleteMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10760,10 +10807,12 @@ const deserializeAws_restJson1DeleteMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10792,8 +10841,7 @@ const deserializeAws_restJson1DeleteMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10818,10 +10866,12 @@ const deserializeAws_restJson1DeleteMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10850,8 +10900,7 @@ const deserializeAws_restJson1DeletePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10876,10 +10925,12 @@ const deserializeAws_restJson1DeletePhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10908,8 +10959,7 @@ const deserializeAws_restJson1DeleteProxySessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10934,10 +10984,12 @@ const deserializeAws_restJson1DeleteProxySessionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10966,8 +11018,7 @@ const deserializeAws_restJson1DeleteRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -10992,10 +11043,12 @@ const deserializeAws_restJson1DeleteRoomCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11024,8 +11077,7 @@ const deserializeAws_restJson1DeleteRoomMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11050,10 +11102,12 @@ const deserializeAws_restJson1DeleteRoomMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11082,8 +11136,7 @@ const deserializeAws_restJson1DeleteSipMediaApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11111,10 +11164,12 @@ const deserializeAws_restJson1DeleteSipMediaApplicationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11143,8 +11198,7 @@ const deserializeAws_restJson1DeleteSipRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11172,10 +11226,12 @@ const deserializeAws_restJson1DeleteSipRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11204,8 +11260,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11233,10 +11288,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11265,8 +11322,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorEmergencyCallingConfigurationC body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11291,10 +11347,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorEmergencyCallingConfigurationC throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11323,8 +11381,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11352,10 +11409,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorGroupCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11384,8 +11443,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorOriginationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11410,10 +11468,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorOriginationCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11442,8 +11502,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11468,10 +11527,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorProxyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11500,8 +11561,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorStreamingConfigurationCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11526,10 +11586,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorStreamingConfigurationCommandE throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11558,8 +11620,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorTerminationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11584,10 +11645,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorTerminationCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11616,8 +11679,7 @@ const deserializeAws_restJson1DeleteVoiceConnectorTerminationCredentialsCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11642,10 +11704,12 @@ const deserializeAws_restJson1DeleteVoiceConnectorTerminationCredentialsCommandE throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11678,8 +11742,7 @@ const deserializeAws_restJson1DescribeAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11701,10 +11764,12 @@ const deserializeAws_restJson1DescribeAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11737,8 +11802,7 @@ const deserializeAws_restJson1DescribeAppInstanceAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11760,10 +11824,12 @@ const deserializeAws_restJson1DescribeAppInstanceAdminCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11796,8 +11862,7 @@ const deserializeAws_restJson1DescribeAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11819,10 +11884,12 @@ const deserializeAws_restJson1DescribeAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11855,8 +11922,7 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11878,10 +11944,12 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11914,8 +11982,7 @@ const deserializeAws_restJson1DescribeChannelBanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -11940,10 +12007,12 @@ const deserializeAws_restJson1DescribeChannelBanCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11976,8 +12045,7 @@ const deserializeAws_restJson1DescribeChannelMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12002,10 +12070,12 @@ const deserializeAws_restJson1DescribeChannelMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12041,8 +12111,7 @@ const deserializeAws_restJson1DescribeChannelMembershipForAppInstanceUserCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12064,10 +12133,12 @@ const deserializeAws_restJson1DescribeChannelMembershipForAppInstanceUserCommand throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12100,8 +12171,7 @@ const deserializeAws_restJson1DescribeChannelModeratedByAppInstanceUserCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12123,10 +12193,12 @@ const deserializeAws_restJson1DescribeChannelModeratedByAppInstanceUserCommandEr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12159,8 +12231,7 @@ const deserializeAws_restJson1DescribeChannelModeratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12185,10 +12256,12 @@ const deserializeAws_restJson1DescribeChannelModeratorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12217,8 +12290,7 @@ const deserializeAws_restJson1DisassociatePhoneNumberFromUserCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12243,10 +12315,12 @@ const deserializeAws_restJson1DisassociatePhoneNumberFromUserCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12279,8 +12353,7 @@ const deserializeAws_restJson1DisassociatePhoneNumbersFromVoiceConnectorCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12305,10 +12378,12 @@ const deserializeAws_restJson1DisassociatePhoneNumbersFromVoiceConnectorCommandE throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12341,8 +12416,7 @@ const deserializeAws_restJson1DisassociatePhoneNumbersFromVoiceConnectorGroupCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12367,10 +12441,12 @@ const deserializeAws_restJson1DisassociatePhoneNumbersFromVoiceConnectorGroupCom throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12399,8 +12475,7 @@ const deserializeAws_restJson1DisassociateSigninDelegateGroupsFromAccountCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12425,10 +12500,12 @@ const deserializeAws_restJson1DisassociateSigninDelegateGroupsFromAccountCommand throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12461,8 +12538,7 @@ const deserializeAws_restJson1GetAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12487,10 +12563,12 @@ const deserializeAws_restJson1GetAccountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12523,8 +12601,7 @@ const deserializeAws_restJson1GetAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12549,10 +12626,12 @@ const deserializeAws_restJson1GetAccountSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12594,8 +12673,7 @@ const deserializeAws_restJson1GetAppInstanceRetentionSettingsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12620,10 +12698,12 @@ const deserializeAws_restJson1GetAppInstanceRetentionSettingsCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12659,8 +12739,7 @@ const deserializeAws_restJson1GetAppInstanceStreamingConfigurationsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12685,10 +12764,12 @@ const deserializeAws_restJson1GetAppInstanceStreamingConfigurationsCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12721,8 +12802,7 @@ const deserializeAws_restJson1GetAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12747,10 +12827,12 @@ const deserializeAws_restJson1GetAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12783,8 +12865,7 @@ const deserializeAws_restJson1GetBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12809,10 +12890,12 @@ const deserializeAws_restJson1GetBotCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12845,8 +12928,7 @@ const deserializeAws_restJson1GetChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12871,10 +12953,12 @@ const deserializeAws_restJson1GetChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12907,8 +12991,7 @@ const deserializeAws_restJson1GetEventsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12933,10 +13016,12 @@ const deserializeAws_restJson1GetEventsConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12973,8 +13058,7 @@ const deserializeAws_restJson1GetGlobalSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -12996,10 +13080,12 @@ const deserializeAws_restJson1GetGlobalSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13032,8 +13118,7 @@ const deserializeAws_restJson1GetMediaCapturePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13058,10 +13143,12 @@ const deserializeAws_restJson1GetMediaCapturePipelineCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13094,8 +13181,7 @@ const deserializeAws_restJson1GetMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13120,10 +13206,12 @@ const deserializeAws_restJson1GetMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13156,8 +13244,7 @@ const deserializeAws_restJson1GetMessagingSessionEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.chime#ForbiddenException": @@ -13176,10 +13263,12 @@ const deserializeAws_restJson1GetMessagingSessionEndpointCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13212,8 +13301,7 @@ const deserializeAws_restJson1GetPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13238,10 +13326,12 @@ const deserializeAws_restJson1GetPhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13274,8 +13364,7 @@ const deserializeAws_restJson1GetPhoneNumberOrderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13300,10 +13389,12 @@ const deserializeAws_restJson1GetPhoneNumberOrderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13340,8 +13431,7 @@ const deserializeAws_restJson1GetPhoneNumberSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13363,10 +13453,12 @@ const deserializeAws_restJson1GetPhoneNumberSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13399,8 +13491,7 @@ const deserializeAws_restJson1GetProxySessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13425,10 +13516,12 @@ const deserializeAws_restJson1GetProxySessionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13465,8 +13558,7 @@ const deserializeAws_restJson1GetRetentionSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13491,10 +13583,12 @@ const deserializeAws_restJson1GetRetentionSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13527,8 +13621,7 @@ const deserializeAws_restJson1GetRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13553,10 +13646,12 @@ const deserializeAws_restJson1GetRoomCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13589,8 +13684,7 @@ const deserializeAws_restJson1GetSipMediaApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13615,10 +13709,12 @@ const deserializeAws_restJson1GetSipMediaApplicationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13657,8 +13753,7 @@ const deserializeAws_restJson1GetSipMediaApplicationLoggingConfigurationCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13683,10 +13778,12 @@ const deserializeAws_restJson1GetSipMediaApplicationLoggingConfigurationCommandE throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13719,8 +13816,7 @@ const deserializeAws_restJson1GetSipRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13745,10 +13841,12 @@ const deserializeAws_restJson1GetSipRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13781,8 +13879,7 @@ const deserializeAws_restJson1GetUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13807,10 +13904,12 @@ const deserializeAws_restJson1GetUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13843,8 +13942,7 @@ const deserializeAws_restJson1GetUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13869,10 +13967,12 @@ const deserializeAws_restJson1GetUserSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13905,8 +14005,7 @@ const deserializeAws_restJson1GetVoiceConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13931,10 +14030,12 @@ const deserializeAws_restJson1GetVoiceConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13970,8 +14071,7 @@ const deserializeAws_restJson1GetVoiceConnectorEmergencyCallingConfigurationComm body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -13996,10 +14096,12 @@ const deserializeAws_restJson1GetVoiceConnectorEmergencyCallingConfigurationComm throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14032,8 +14134,7 @@ const deserializeAws_restJson1GetVoiceConnectorGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14058,10 +14159,12 @@ const deserializeAws_restJson1GetVoiceConnectorGroupCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14094,8 +14197,7 @@ const deserializeAws_restJson1GetVoiceConnectorLoggingConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14120,10 +14222,12 @@ const deserializeAws_restJson1GetVoiceConnectorLoggingConfigurationCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14156,8 +14260,7 @@ const deserializeAws_restJson1GetVoiceConnectorOriginationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14182,10 +14285,12 @@ const deserializeAws_restJson1GetVoiceConnectorOriginationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14218,8 +14323,7 @@ const deserializeAws_restJson1GetVoiceConnectorProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14244,10 +14348,12 @@ const deserializeAws_restJson1GetVoiceConnectorProxyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14283,8 +14389,7 @@ const deserializeAws_restJson1GetVoiceConnectorStreamingConfigurationCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14309,10 +14414,12 @@ const deserializeAws_restJson1GetVoiceConnectorStreamingConfigurationCommandErro throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14345,8 +14452,7 @@ const deserializeAws_restJson1GetVoiceConnectorTerminationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14371,10 +14477,12 @@ const deserializeAws_restJson1GetVoiceConnectorTerminationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14407,8 +14515,7 @@ const deserializeAws_restJson1GetVoiceConnectorTerminationHealthCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14433,10 +14540,12 @@ const deserializeAws_restJson1GetVoiceConnectorTerminationHealthCommandError = a throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14469,8 +14578,7 @@ const deserializeAws_restJson1InviteUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14495,10 +14603,12 @@ const deserializeAws_restJson1InviteUsersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14535,8 +14645,7 @@ const deserializeAws_restJson1ListAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14561,10 +14670,12 @@ const deserializeAws_restJson1ListAccountsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14605,8 +14716,7 @@ const deserializeAws_restJson1ListAppInstanceAdminsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14628,10 +14738,12 @@ const deserializeAws_restJson1ListAppInstanceAdminsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14668,8 +14780,7 @@ const deserializeAws_restJson1ListAppInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14691,10 +14802,12 @@ const deserializeAws_restJson1ListAppInstancesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14735,8 +14848,7 @@ const deserializeAws_restJson1ListAppInstanceUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14758,10 +14870,12 @@ const deserializeAws_restJson1ListAppInstanceUsersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14798,8 +14912,7 @@ const deserializeAws_restJson1ListAttendeesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14824,10 +14937,12 @@ const deserializeAws_restJson1ListAttendeesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14860,8 +14975,7 @@ const deserializeAws_restJson1ListAttendeeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14886,10 +15000,12 @@ const deserializeAws_restJson1ListAttendeeTagsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14926,8 +15042,7 @@ const deserializeAws_restJson1ListBotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -14952,10 +15067,12 @@ const deserializeAws_restJson1ListBotsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14996,8 +15113,7 @@ const deserializeAws_restJson1ListChannelBansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15019,10 +15135,12 @@ const deserializeAws_restJson1ListChannelBansCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15066,8 +15184,7 @@ const deserializeAws_restJson1ListChannelMembershipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15089,10 +15206,12 @@ const deserializeAws_restJson1ListChannelMembershipsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15132,8 +15251,7 @@ const deserializeAws_restJson1ListChannelMembershipsForAppInstanceUserCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15155,10 +15273,12 @@ const deserializeAws_restJson1ListChannelMembershipsForAppInstanceUserCommandErr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15199,8 +15319,7 @@ const deserializeAws_restJson1ListChannelMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15222,10 +15341,12 @@ const deserializeAws_restJson1ListChannelMessagesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15266,8 +15387,7 @@ const deserializeAws_restJson1ListChannelModeratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15289,10 +15409,12 @@ const deserializeAws_restJson1ListChannelModeratorsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15329,8 +15451,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15352,10 +15473,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15392,8 +15515,7 @@ const deserializeAws_restJson1ListChannelsModeratedByAppInstanceUserCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15415,10 +15537,12 @@ const deserializeAws_restJson1ListChannelsModeratedByAppInstanceUserCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15458,8 +15582,7 @@ const deserializeAws_restJson1ListMediaCapturePipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15481,10 +15604,12 @@ const deserializeAws_restJson1ListMediaCapturePipelinesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15521,8 +15646,7 @@ const deserializeAws_restJson1ListMeetingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15544,10 +15668,12 @@ const deserializeAws_restJson1ListMeetingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15580,8 +15706,7 @@ const deserializeAws_restJson1ListMeetingTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15606,10 +15731,12 @@ const deserializeAws_restJson1ListMeetingTagsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15646,8 +15773,7 @@ const deserializeAws_restJson1ListPhoneNumberOrdersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15669,10 +15795,12 @@ const deserializeAws_restJson1ListPhoneNumberOrdersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15709,8 +15837,7 @@ const deserializeAws_restJson1ListPhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15735,10 +15862,12 @@ const deserializeAws_restJson1ListPhoneNumbersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15775,8 +15904,7 @@ const deserializeAws_restJson1ListProxySessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15801,10 +15929,12 @@ const deserializeAws_restJson1ListProxySessionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15841,8 +15971,7 @@ const deserializeAws_restJson1ListRoomMembershipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15867,10 +15996,12 @@ const deserializeAws_restJson1ListRoomMembershipsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15907,8 +16038,7 @@ const deserializeAws_restJson1ListRoomsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15933,10 +16063,12 @@ const deserializeAws_restJson1ListRoomsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15973,8 +16105,7 @@ const deserializeAws_restJson1ListSipMediaApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -15996,10 +16127,12 @@ const deserializeAws_restJson1ListSipMediaApplicationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16036,8 +16169,7 @@ const deserializeAws_restJson1ListSipRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16059,10 +16191,12 @@ const deserializeAws_restJson1ListSipRulesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16098,8 +16232,7 @@ const deserializeAws_restJson1ListSupportedPhoneNumberCountriesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -16124,10 +16257,12 @@ const deserializeAws_restJson1ListSupportedPhoneNumberCountriesCommandError = as throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16160,8 +16295,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16183,10 +16317,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16223,8 +16359,7 @@ const deserializeAws_restJson1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16249,10 +16384,12 @@ const deserializeAws_restJson1ListUsersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16289,8 +16426,7 @@ const deserializeAws_restJson1ListVoiceConnectorGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16312,10 +16448,12 @@ const deserializeAws_restJson1ListVoiceConnectorGroupsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16352,8 +16490,7 @@ const deserializeAws_restJson1ListVoiceConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16375,10 +16512,12 @@ const deserializeAws_restJson1ListVoiceConnectorsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16411,8 +16550,7 @@ const deserializeAws_restJson1ListVoiceConnectorTerminationCredentialsCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16437,10 +16575,12 @@ const deserializeAws_restJson1ListVoiceConnectorTerminationCredentialsCommandErr throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16469,8 +16609,7 @@ const deserializeAws_restJson1LogoutUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16495,10 +16634,12 @@ const deserializeAws_restJson1LogoutUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16540,8 +16681,7 @@ const deserializeAws_restJson1PutAppInstanceRetentionSettingsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16569,10 +16709,12 @@ const deserializeAws_restJson1PutAppInstanceRetentionSettingsCommandError = asyn throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16608,8 +16750,7 @@ const deserializeAws_restJson1PutAppInstanceStreamingConfigurationsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16634,10 +16775,12 @@ const deserializeAws_restJson1PutAppInstanceStreamingConfigurationsCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16670,8 +16813,7 @@ const deserializeAws_restJson1PutEventsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16696,10 +16838,12 @@ const deserializeAws_restJson1PutEventsConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16736,8 +16880,7 @@ const deserializeAws_restJson1PutRetentionSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16765,10 +16908,12 @@ const deserializeAws_restJson1PutRetentionSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16807,8 +16952,7 @@ const deserializeAws_restJson1PutSipMediaApplicationLoggingConfigurationCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16833,10 +16977,12 @@ const deserializeAws_restJson1PutSipMediaApplicationLoggingConfigurationCommandE throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16872,8 +17018,7 @@ const deserializeAws_restJson1PutVoiceConnectorEmergencyCallingConfigurationComm body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16898,10 +17043,12 @@ const deserializeAws_restJson1PutVoiceConnectorEmergencyCallingConfigurationComm throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16934,8 +17081,7 @@ const deserializeAws_restJson1PutVoiceConnectorLoggingConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -16960,10 +17106,12 @@ const deserializeAws_restJson1PutVoiceConnectorLoggingConfigurationCommandError throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16996,8 +17144,7 @@ const deserializeAws_restJson1PutVoiceConnectorOriginationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17022,10 +17169,12 @@ const deserializeAws_restJson1PutVoiceConnectorOriginationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17058,8 +17207,7 @@ const deserializeAws_restJson1PutVoiceConnectorProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -17087,10 +17235,12 @@ const deserializeAws_restJson1PutVoiceConnectorProxyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17126,8 +17276,7 @@ const deserializeAws_restJson1PutVoiceConnectorStreamingConfigurationCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17152,10 +17301,12 @@ const deserializeAws_restJson1PutVoiceConnectorStreamingConfigurationCommandErro throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17188,8 +17339,7 @@ const deserializeAws_restJson1PutVoiceConnectorTerminationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -17217,10 +17367,12 @@ const deserializeAws_restJson1PutVoiceConnectorTerminationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17249,8 +17401,7 @@ const deserializeAws_restJson1PutVoiceConnectorTerminationCredentialsCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17275,10 +17426,12 @@ const deserializeAws_restJson1PutVoiceConnectorTerminationCredentialsCommandErro throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17315,8 +17468,7 @@ const deserializeAws_restJson1RedactChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17338,10 +17490,12 @@ const deserializeAws_restJson1RedactChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17370,8 +17524,7 @@ const deserializeAws_restJson1RedactConversationMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17396,10 +17549,12 @@ const deserializeAws_restJson1RedactConversationMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17428,8 +17583,7 @@ const deserializeAws_restJson1RedactRoomMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17454,10 +17608,12 @@ const deserializeAws_restJson1RedactRoomMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17490,8 +17646,7 @@ const deserializeAws_restJson1RegenerateSecurityTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17516,10 +17671,12 @@ const deserializeAws_restJson1RegenerateSecurityTokenCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17552,8 +17709,7 @@ const deserializeAws_restJson1ResetPersonalPINCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17578,10 +17734,12 @@ const deserializeAws_restJson1ResetPersonalPINCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17614,8 +17772,7 @@ const deserializeAws_restJson1RestorePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17643,10 +17800,12 @@ const deserializeAws_restJson1RestorePhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17683,8 +17842,7 @@ const deserializeAws_restJson1SearchAvailablePhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.chime#AccessDeniedException": @@ -17709,10 +17867,12 @@ const deserializeAws_restJson1SearchAvailablePhoneNumbersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17749,8 +17909,7 @@ const deserializeAws_restJson1SendChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17775,10 +17934,12 @@ const deserializeAws_restJson1SendChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17807,8 +17968,7 @@ const deserializeAws_restJson1StartMeetingTranscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17839,10 +17999,12 @@ const deserializeAws_restJson1StartMeetingTranscriptionCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17871,8 +18033,7 @@ const deserializeAws_restJson1StopMeetingTranscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17900,10 +18061,12 @@ const deserializeAws_restJson1StopMeetingTranscriptionCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17932,8 +18095,7 @@ const deserializeAws_restJson1TagAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -17961,10 +18123,12 @@ const deserializeAws_restJson1TagAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17993,8 +18157,7 @@ const deserializeAws_restJson1TagMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18022,10 +18185,12 @@ const deserializeAws_restJson1TagMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18054,8 +18219,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18077,10 +18241,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18109,8 +18275,7 @@ const deserializeAws_restJson1UntagAttendeeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18135,10 +18300,12 @@ const deserializeAws_restJson1UntagAttendeeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18167,8 +18334,7 @@ const deserializeAws_restJson1UntagMeetingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18193,10 +18359,12 @@ const deserializeAws_restJson1UntagMeetingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18225,8 +18393,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18248,10 +18415,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18284,8 +18453,7 @@ const deserializeAws_restJson1UpdateAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18310,10 +18478,12 @@ const deserializeAws_restJson1UpdateAccountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18342,8 +18512,7 @@ const deserializeAws_restJson1UpdateAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18371,10 +18540,12 @@ const deserializeAws_restJson1UpdateAccountSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18407,8 +18578,7 @@ const deserializeAws_restJson1UpdateAppInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18433,10 +18603,12 @@ const deserializeAws_restJson1UpdateAppInstanceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18469,8 +18641,7 @@ const deserializeAws_restJson1UpdateAppInstanceUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18495,10 +18666,12 @@ const deserializeAws_restJson1UpdateAppInstanceUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18531,8 +18704,7 @@ const deserializeAws_restJson1UpdateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18557,10 +18729,12 @@ const deserializeAws_restJson1UpdateBotCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18593,8 +18767,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18619,10 +18792,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18659,8 +18834,7 @@ const deserializeAws_restJson1UpdateChannelMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18685,10 +18859,12 @@ const deserializeAws_restJson1UpdateChannelMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18721,8 +18897,7 @@ const deserializeAws_restJson1UpdateChannelReadMarkerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18747,10 +18922,12 @@ const deserializeAws_restJson1UpdateChannelReadMarkerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18779,8 +18956,7 @@ const deserializeAws_restJson1UpdateGlobalSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18802,10 +18978,12 @@ const deserializeAws_restJson1UpdateGlobalSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18838,8 +19016,7 @@ const deserializeAws_restJson1UpdatePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18867,10 +19044,12 @@ const deserializeAws_restJson1UpdatePhoneNumberCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18899,8 +19078,7 @@ const deserializeAws_restJson1UpdatePhoneNumberSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18922,10 +19100,12 @@ const deserializeAws_restJson1UpdatePhoneNumberSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18958,8 +19138,7 @@ const deserializeAws_restJson1UpdateProxySessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -18984,10 +19163,12 @@ const deserializeAws_restJson1UpdateProxySessionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19020,8 +19201,7 @@ const deserializeAws_restJson1UpdateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19046,10 +19226,12 @@ const deserializeAws_restJson1UpdateRoomCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19082,8 +19264,7 @@ const deserializeAws_restJson1UpdateRoomMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19108,10 +19289,12 @@ const deserializeAws_restJson1UpdateRoomMembershipCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19144,8 +19327,7 @@ const deserializeAws_restJson1UpdateSipMediaApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19173,10 +19355,12 @@ const deserializeAws_restJson1UpdateSipMediaApplicationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19212,8 +19396,7 @@ const deserializeAws_restJson1UpdateSipMediaApplicationCallCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19241,10 +19424,12 @@ const deserializeAws_restJson1UpdateSipMediaApplicationCallCommandError = async throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19277,8 +19462,7 @@ const deserializeAws_restJson1UpdateSipRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19309,10 +19493,12 @@ const deserializeAws_restJson1UpdateSipRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19345,8 +19531,7 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19371,10 +19556,12 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19403,8 +19590,7 @@ const deserializeAws_restJson1UpdateUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19429,10 +19615,12 @@ const deserializeAws_restJson1UpdateUserSettingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19465,8 +19653,7 @@ const deserializeAws_restJson1UpdateVoiceConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19491,10 +19678,12 @@ const deserializeAws_restJson1UpdateVoiceConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19527,8 +19716,7 @@ const deserializeAws_restJson1UpdateVoiceConnectorGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.chime#BadRequestException": @@ -19556,10 +19744,12 @@ const deserializeAws_restJson1UpdateVoiceConnectorGroupCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22583,7 +22773,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -22609,6 +22799,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloud9/src/protocols/Aws_json1_1.ts b/clients/client-cloud9/src/protocols/Aws_json1_1.ts index 021bb4b80a398..4e378f62fe87a 100644 --- a/clients/client-cloud9/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloud9/src/protocols/Aws_json1_1.ts @@ -290,8 +290,7 @@ const deserializeAws_json1_1CreateEnvironmentEC2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -316,10 +315,12 @@ const deserializeAws_json1_1CreateEnvironmentEC2CommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -351,8 +352,7 @@ const deserializeAws_json1_1CreateEnvironmentMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -377,10 +377,12 @@ const deserializeAws_json1_1CreateEnvironmentMembershipCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -412,8 +414,7 @@ const deserializeAws_json1_1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -438,10 +439,12 @@ const deserializeAws_json1_1DeleteEnvironmentCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -473,8 +476,7 @@ const deserializeAws_json1_1DeleteEnvironmentMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -499,10 +501,12 @@ const deserializeAws_json1_1DeleteEnvironmentMembershipCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -534,8 +538,7 @@ const deserializeAws_json1_1DescribeEnvironmentMembershipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -560,10 +563,12 @@ const deserializeAws_json1_1DescribeEnvironmentMembershipsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -595,8 +600,7 @@ const deserializeAws_json1_1DescribeEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -621,10 +625,12 @@ const deserializeAws_json1_1DescribeEnvironmentsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -656,8 +662,7 @@ const deserializeAws_json1_1DescribeEnvironmentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -682,10 +687,12 @@ const deserializeAws_json1_1DescribeEnvironmentStatusCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -717,8 +724,7 @@ const deserializeAws_json1_1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -743,10 +749,12 @@ const deserializeAws_json1_1ListEnvironmentsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -778,8 +786,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -792,10 +799,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -827,8 +836,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -844,10 +852,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -879,8 +889,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -896,10 +905,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -931,8 +942,7 @@ const deserializeAws_json1_1UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -957,10 +967,12 @@ const deserializeAws_json1_1UpdateEnvironmentCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -992,8 +1004,7 @@ const deserializeAws_json1_1UpdateEnvironmentMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.cloud9#BadRequestException": @@ -1018,10 +1029,12 @@ const deserializeAws_json1_1UpdateEnvironmentMembershipCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1664,7 +1677,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1690,6 +1703,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudcontrol/src/protocols/Aws_json1_0.ts b/clients/client-cloudcontrol/src/protocols/Aws_json1_0.ts index 368326ead30a1..881992c637616 100644 --- a/clients/client-cloudcontrol/src/protocols/Aws_json1_0.ts +++ b/clients/client-cloudcontrol/src/protocols/Aws_json1_0.ts @@ -208,8 +208,7 @@ const deserializeAws_json1_0CancelResourceRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudcontrol#ConcurrentModificationException": @@ -219,10 +218,12 @@ const deserializeAws_json1_0CancelResourceRequestCommandError = async ( throw await deserializeAws_json1_0RequestTokenNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -254,8 +255,7 @@ const deserializeAws_json1_0CreateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudcontrol#AlreadyExistsException": @@ -316,10 +316,12 @@ const deserializeAws_json1_0CreateResourceCommandError = async ( throw await deserializeAws_json1_0UnsupportedActionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -351,8 +353,7 @@ const deserializeAws_json1_0DeleteResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudcontrol#AlreadyExistsException": @@ -413,10 +414,12 @@ const deserializeAws_json1_0DeleteResourceCommandError = async ( throw await deserializeAws_json1_0UnsupportedActionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -448,8 +451,7 @@ const deserializeAws_json1_0GetResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudcontrol#AlreadyExistsException": @@ -504,10 +506,12 @@ const deserializeAws_json1_0GetResourceCommandError = async ( throw await deserializeAws_json1_0UnsupportedActionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -539,18 +543,19 @@ const deserializeAws_json1_0GetResourceRequestStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestTokenNotFoundException": case "com.amazonaws.cloudcontrol#RequestTokenNotFoundException": throw await deserializeAws_json1_0RequestTokenNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -582,15 +587,16 @@ const deserializeAws_json1_0ListResourceRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -622,8 +628,7 @@ const deserializeAws_json1_0ListResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudcontrol#AlreadyExistsException": @@ -678,10 +683,12 @@ const deserializeAws_json1_0ListResourcesCommandError = async ( throw await deserializeAws_json1_0UnsupportedActionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -713,8 +720,7 @@ const deserializeAws_json1_0UpdateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudcontrol#AlreadyExistsException": @@ -775,10 +781,12 @@ const deserializeAws_json1_0UpdateResourceCommandError = async ( throw await deserializeAws_json1_0UnsupportedActionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1545,7 +1553,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1571,6 +1579,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-clouddirectory/src/protocols/Aws_restJson1.ts b/clients/client-clouddirectory/src/protocols/Aws_restJson1.ts index d2a9609a17154..2db79f588aefb 100644 --- a/clients/client-clouddirectory/src/protocols/Aws_restJson1.ts +++ b/clients/client-clouddirectory/src/protocols/Aws_restJson1.ts @@ -2340,8 +2340,7 @@ const deserializeAws_restJson1AddFacetToObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2372,10 +2371,12 @@ const deserializeAws_restJson1AddFacetToObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2412,8 +2413,7 @@ const deserializeAws_restJson1ApplySchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2444,10 +2444,12 @@ const deserializeAws_restJson1ApplySchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2482,7 @@ const deserializeAws_restJson1AttachObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2518,10 +2519,12 @@ const deserializeAws_restJson1AttachObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2550,8 +2553,7 @@ const deserializeAws_restJson1AttachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2582,10 +2584,12 @@ const deserializeAws_restJson1AttachPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2618,8 +2622,7 @@ const deserializeAws_restJson1AttachToIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2659,10 +2662,12 @@ const deserializeAws_restJson1AttachToIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2695,8 +2700,7 @@ const deserializeAws_restJson1AttachTypedLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2730,10 +2734,12 @@ const deserializeAws_restJson1AttachTypedLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2766,8 +2772,7 @@ const deserializeAws_restJson1BatchReadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2792,10 +2797,12 @@ const deserializeAws_restJson1BatchReadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2828,8 +2835,7 @@ const deserializeAws_restJson1BatchWriteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2857,10 +2863,12 @@ const deserializeAws_restJson1BatchWriteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2905,8 +2913,7 @@ const deserializeAws_restJson1CreateDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -2934,10 +2941,12 @@ const deserializeAws_restJson1CreateDirectoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2966,8 +2975,7 @@ const deserializeAws_restJson1CreateFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3001,10 +3009,12 @@ const deserializeAws_restJson1CreateFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3037,8 +3047,7 @@ const deserializeAws_restJson1CreateIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3075,10 +3084,12 @@ const deserializeAws_restJson1CreateIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3111,8 +3122,7 @@ const deserializeAws_restJson1CreateObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3149,10 +3159,12 @@ const deserializeAws_restJson1CreateObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3185,8 +3197,7 @@ const deserializeAws_restJson1CreateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3211,10 +3222,12 @@ const deserializeAws_restJson1CreateSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3243,8 +3256,7 @@ const deserializeAws_restJson1CreateTypedLinkFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3278,10 +3290,12 @@ const deserializeAws_restJson1CreateTypedLinkFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3314,8 +3328,7 @@ const deserializeAws_restJson1DeleteDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3346,10 +3359,12 @@ const deserializeAws_restJson1DeleteDirectoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3378,8 +3393,7 @@ const deserializeAws_restJson1DeleteFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3410,10 +3424,12 @@ const deserializeAws_restJson1DeleteFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3442,8 +3458,7 @@ const deserializeAws_restJson1DeleteObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3474,10 +3489,12 @@ const deserializeAws_restJson1DeleteObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3510,8 +3527,7 @@ const deserializeAws_restJson1DeleteSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3539,10 +3555,12 @@ const deserializeAws_restJson1DeleteSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3571,8 +3589,7 @@ const deserializeAws_restJson1DeleteTypedLinkFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3600,10 +3617,12 @@ const deserializeAws_restJson1DeleteTypedLinkFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3636,8 +3655,7 @@ const deserializeAws_restJson1DetachFromIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3671,10 +3689,12 @@ const deserializeAws_restJson1DetachFromIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3707,8 +3727,7 @@ const deserializeAws_restJson1DetachObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3739,10 +3758,12 @@ const deserializeAws_restJson1DetachObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3771,8 +3792,7 @@ const deserializeAws_restJson1DetachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3803,10 +3823,12 @@ const deserializeAws_restJson1DetachPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3835,8 +3857,7 @@ const deserializeAws_restJson1DetachTypedLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3867,10 +3888,12 @@ const deserializeAws_restJson1DetachTypedLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3903,8 +3926,7 @@ const deserializeAws_restJson1DisableDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3932,10 +3954,12 @@ const deserializeAws_restJson1DisableDirectoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3968,8 +3992,7 @@ const deserializeAws_restJson1EnableDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -3997,10 +4020,12 @@ const deserializeAws_restJson1EnableDirectoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4033,8 +4058,7 @@ const deserializeAws_restJson1GetAppliedSchemaVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4059,10 +4083,12 @@ const deserializeAws_restJson1GetAppliedSchemaVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4095,8 +4121,7 @@ const deserializeAws_restJson1GetDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4118,10 +4143,12 @@ const deserializeAws_restJson1GetDirectoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4154,8 +4181,7 @@ const deserializeAws_restJson1GetFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4183,10 +4209,12 @@ const deserializeAws_restJson1GetFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4219,8 +4247,7 @@ const deserializeAws_restJson1GetLinkAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4251,10 +4278,12 @@ const deserializeAws_restJson1GetLinkAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4287,8 +4316,7 @@ const deserializeAws_restJson1GetObjectAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4319,10 +4347,12 @@ const deserializeAws_restJson1GetObjectAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4359,8 +4389,7 @@ const deserializeAws_restJson1GetObjectInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4388,10 +4417,12 @@ const deserializeAws_restJson1GetObjectInformationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4428,8 +4459,7 @@ const deserializeAws_restJson1GetSchemaAsJsonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4454,10 +4484,12 @@ const deserializeAws_restJson1GetSchemaAsJsonCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4490,8 +4522,7 @@ const deserializeAws_restJson1GetTypedLinkFacetInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4522,10 +4553,12 @@ const deserializeAws_restJson1GetTypedLinkFacetInformationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4562,8 +4595,7 @@ const deserializeAws_restJson1ListAppliedSchemaArnsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4591,10 +4623,12 @@ const deserializeAws_restJson1ListAppliedSchemaArnsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4631,8 +4665,7 @@ const deserializeAws_restJson1ListAttachedIndicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4660,10 +4693,12 @@ const deserializeAws_restJson1ListAttachedIndicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4700,8 +4735,7 @@ const deserializeAws_restJson1ListDevelopmentSchemaArnsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4729,10 +4763,12 @@ const deserializeAws_restJson1ListDevelopmentSchemaArnsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4769,8 +4805,7 @@ const deserializeAws_restJson1ListDirectoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4795,10 +4830,12 @@ const deserializeAws_restJson1ListDirectoriesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4835,8 +4872,7 @@ const deserializeAws_restJson1ListFacetAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4867,10 +4903,12 @@ const deserializeAws_restJson1ListFacetAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4907,8 +4945,7 @@ const deserializeAws_restJson1ListFacetNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -4936,10 +4973,12 @@ const deserializeAws_restJson1ListFacetNamesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4976,8 +5015,7 @@ const deserializeAws_restJson1ListIncomingTypedLinksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5011,10 +5049,12 @@ const deserializeAws_restJson1ListIncomingTypedLinksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5051,8 +5091,7 @@ const deserializeAws_restJson1ListIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5089,10 +5128,12 @@ const deserializeAws_restJson1ListIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5129,8 +5170,7 @@ const deserializeAws_restJson1ListManagedSchemaArnsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5152,10 +5192,12 @@ const deserializeAws_restJson1ListManagedSchemaArnsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5192,8 +5234,7 @@ const deserializeAws_restJson1ListObjectAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5227,10 +5268,12 @@ const deserializeAws_restJson1ListObjectAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5267,8 +5310,7 @@ const deserializeAws_restJson1ListObjectChildrenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5302,10 +5344,12 @@ const deserializeAws_restJson1ListObjectChildrenCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5345,8 +5389,7 @@ const deserializeAws_restJson1ListObjectParentPathsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5377,10 +5420,12 @@ const deserializeAws_restJson1ListObjectParentPathsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5421,8 +5466,7 @@ const deserializeAws_restJson1ListObjectParentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5456,10 +5500,12 @@ const deserializeAws_restJson1ListObjectParentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5496,8 +5542,7 @@ const deserializeAws_restJson1ListObjectPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5528,10 +5573,12 @@ const deserializeAws_restJson1ListObjectPoliciesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5568,8 +5615,7 @@ const deserializeAws_restJson1ListOutgoingTypedLinksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5603,10 +5649,12 @@ const deserializeAws_restJson1ListOutgoingTypedLinksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5643,8 +5691,7 @@ const deserializeAws_restJson1ListPolicyAttachmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5678,10 +5725,12 @@ const deserializeAws_restJson1ListPolicyAttachmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5718,8 +5767,7 @@ const deserializeAws_restJson1ListPublishedSchemaArnsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5747,10 +5795,12 @@ const deserializeAws_restJson1ListPublishedSchemaArnsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5787,8 +5837,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5816,10 +5865,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5856,8 +5907,7 @@ const deserializeAws_restJson1ListTypedLinkFacetAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5888,10 +5938,12 @@ const deserializeAws_restJson1ListTypedLinkFacetAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5928,8 +5980,7 @@ const deserializeAws_restJson1ListTypedLinkFacetNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -5957,10 +6008,12 @@ const deserializeAws_restJson1ListTypedLinkFacetNamesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5997,8 +6050,7 @@ const deserializeAws_restJson1LookupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6029,10 +6081,12 @@ const deserializeAws_restJson1LookupPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6065,8 +6119,7 @@ const deserializeAws_restJson1PublishSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6094,10 +6147,12 @@ const deserializeAws_restJson1PublishSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6130,8 +6185,7 @@ const deserializeAws_restJson1PutSchemaFromJsonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6159,10 +6213,12 @@ const deserializeAws_restJson1PutSchemaFromJsonCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6191,8 +6247,7 @@ const deserializeAws_restJson1RemoveFacetFromObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6223,10 +6278,12 @@ const deserializeAws_restJson1RemoveFacetFromObjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6255,8 +6312,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6284,10 +6340,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6316,8 +6374,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6345,10 +6402,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6377,8 +6436,7 @@ const deserializeAws_restJson1UpdateFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6415,10 +6473,12 @@ const deserializeAws_restJson1UpdateFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6447,8 +6507,7 @@ const deserializeAws_restJson1UpdateLinkAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6479,10 +6538,12 @@ const deserializeAws_restJson1UpdateLinkAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6515,8 +6576,7 @@ const deserializeAws_restJson1UpdateObjectAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6550,10 +6610,12 @@ const deserializeAws_restJson1UpdateObjectAttributesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6586,8 +6648,7 @@ const deserializeAws_restJson1UpdateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6612,10 +6673,12 @@ const deserializeAws_restJson1UpdateSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6644,8 +6707,7 @@ const deserializeAws_restJson1UpdateTypedLinkFacetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6682,10 +6744,12 @@ const deserializeAws_restJson1UpdateTypedLinkFacetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6722,8 +6786,7 @@ const deserializeAws_restJson1UpgradeAppliedSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6754,10 +6817,12 @@ const deserializeAws_restJson1UpgradeAppliedSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6790,8 +6855,7 @@ const deserializeAws_restJson1UpgradePublishedSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.clouddirectory#AccessDeniedException": @@ -6822,10 +6886,12 @@ const deserializeAws_restJson1UpgradePublishedSchemaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9529,7 +9595,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9555,6 +9621,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudformation/src/protocols/Aws_query.ts b/clients/client-cloudformation/src/protocols/Aws_query.ts index 08a3285b8913c..1f11d276a5609 100644 --- a/clients/client-cloudformation/src/protocols/Aws_query.ts +++ b/clients/client-cloudformation/src/protocols/Aws_query.ts @@ -1466,8 +1466,7 @@ const deserializeAws_queryActivateTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -1477,10 +1476,12 @@ const deserializeAws_queryActivateTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1515,8 +1516,7 @@ const deserializeAws_queryBatchDescribeTypeConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -1526,10 +1526,12 @@ const deserializeAws_queryBatchDescribeTypeConfigurationsCommandError = async ( throw await deserializeAws_queryTypeConfigurationNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1558,18 +1560,19 @@ const deserializeAws_queryCancelUpdateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TokenAlreadyExistsException": case "com.amazonaws.cloudformation#TokenAlreadyExistsException": throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1601,18 +1604,19 @@ const deserializeAws_queryContinueUpdateRollbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TokenAlreadyExistsException": case "com.amazonaws.cloudformation#TokenAlreadyExistsException": throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1644,8 +1648,7 @@ const deserializeAws_queryCreateChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudformation#AlreadyExistsException": @@ -1658,10 +1661,12 @@ const deserializeAws_queryCreateChangeSetCommandError = async ( throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1693,8 +1698,7 @@ const deserializeAws_queryCreateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.cloudformation#AlreadyExistsException": @@ -1710,10 +1714,12 @@ const deserializeAws_queryCreateStackCommandError = async ( throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1745,8 +1751,7 @@ const deserializeAws_queryCreateStackInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -1768,10 +1773,12 @@ const deserializeAws_queryCreateStackInstancesCommandError = async ( throw await deserializeAws_queryStaleRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1803,8 +1810,7 @@ const deserializeAws_queryCreateStackSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CreatedButModifiedException": case "com.amazonaws.cloudformation#CreatedButModifiedException": @@ -1817,10 +1823,12 @@ const deserializeAws_queryCreateStackSetCommandError = async ( throw await deserializeAws_queryNameAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1852,8 +1860,7 @@ const deserializeAws_queryDeactivateTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -1863,10 +1870,12 @@ const deserializeAws_queryDeactivateTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1898,18 +1907,19 @@ const deserializeAws_queryDeleteChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidChangeSetStatusException": case "com.amazonaws.cloudformation#InvalidChangeSetStatusException": throw await deserializeAws_queryInvalidChangeSetStatusExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1938,18 +1948,19 @@ const deserializeAws_queryDeleteStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TokenAlreadyExistsException": case "com.amazonaws.cloudformation#TokenAlreadyExistsException": throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1981,8 +1992,7 @@ const deserializeAws_queryDeleteStackInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -2001,10 +2011,12 @@ const deserializeAws_queryDeleteStackInstancesCommandError = async ( throw await deserializeAws_queryStaleRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2036,8 +2048,7 @@ const deserializeAws_queryDeleteStackSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationInProgressException": case "com.amazonaws.cloudformation#OperationInProgressException": @@ -2047,10 +2058,12 @@ const deserializeAws_queryDeleteStackSetCommandError = async ( throw await deserializeAws_queryStackSetNotEmptyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2082,8 +2095,7 @@ const deserializeAws_queryDeregisterTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -2093,10 +2105,12 @@ const deserializeAws_queryDeregisterTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2128,15 +2142,16 @@ const deserializeAws_queryDescribeAccountLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2168,18 +2183,19 @@ const deserializeAws_queryDescribeChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ChangeSetNotFoundException": case "com.amazonaws.cloudformation#ChangeSetNotFoundException": throw await deserializeAws_queryChangeSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2211,18 +2227,19 @@ const deserializeAws_queryDescribeChangeSetHooksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ChangeSetNotFoundException": case "com.amazonaws.cloudformation#ChangeSetNotFoundException": throw await deserializeAws_queryChangeSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2254,18 +2271,19 @@ const deserializeAws_queryDescribePublisherCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2300,15 +2318,16 @@ const deserializeAws_queryDescribeStackDriftDetectionStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2340,15 +2359,16 @@ const deserializeAws_queryDescribeStackEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2380,8 +2400,7 @@ const deserializeAws_queryDescribeStackInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "StackInstanceNotFoundException": case "com.amazonaws.cloudformation#StackInstanceNotFoundException": @@ -2391,10 +2410,12 @@ const deserializeAws_queryDescribeStackInstanceCommandError = async ( throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2426,15 +2447,16 @@ const deserializeAws_queryDescribeStackResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2466,15 +2488,16 @@ const deserializeAws_queryDescribeStackResourceDriftsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2506,15 +2529,16 @@ const deserializeAws_queryDescribeStackResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2546,15 +2570,16 @@ const deserializeAws_queryDescribeStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2586,18 +2611,19 @@ const deserializeAws_queryDescribeStackSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "StackSetNotFoundException": case "com.amazonaws.cloudformation#StackSetNotFoundException": throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2629,8 +2655,7 @@ const deserializeAws_queryDescribeStackSetOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotFoundException": case "com.amazonaws.cloudformation#OperationNotFoundException": @@ -2640,10 +2665,12 @@ const deserializeAws_queryDescribeStackSetOperationCommandError = async ( throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2675,8 +2702,7 @@ const deserializeAws_queryDescribeTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -2686,10 +2712,12 @@ const deserializeAws_queryDescribeTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2721,18 +2749,19 @@ const deserializeAws_queryDescribeTypeRegistrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2764,15 +2793,16 @@ const deserializeAws_queryDetectStackDriftCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2804,15 +2834,16 @@ const deserializeAws_queryDetectStackResourceDriftCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2844,8 +2875,7 @@ const deserializeAws_queryDetectStackSetDriftCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -2858,10 +2888,12 @@ const deserializeAws_queryDetectStackSetDriftCommandError = async ( throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2893,15 +2925,16 @@ const deserializeAws_queryEstimateTemplateCostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2933,8 +2966,7 @@ const deserializeAws_queryExecuteChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ChangeSetNotFoundException": case "com.amazonaws.cloudformation#ChangeSetNotFoundException": @@ -2950,10 +2982,12 @@ const deserializeAws_queryExecuteChangeSetCommandError = async ( throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2985,15 +3019,16 @@ const deserializeAws_queryGetStackPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3025,18 +3060,19 @@ const deserializeAws_queryGetTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ChangeSetNotFoundException": case "com.amazonaws.cloudformation#ChangeSetNotFoundException": throw await deserializeAws_queryChangeSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3068,18 +3104,19 @@ const deserializeAws_queryGetTemplateSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "StackSetNotFoundException": case "com.amazonaws.cloudformation#StackSetNotFoundException": throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3111,8 +3148,7 @@ const deserializeAws_queryImportStacksToStackSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -3137,10 +3173,12 @@ const deserializeAws_queryImportStacksToStackSetCommandError = async ( throw await deserializeAws_queryStaleRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3172,15 +3210,16 @@ const deserializeAws_queryListChangeSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3212,15 +3251,16 @@ const deserializeAws_queryListExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3252,15 +3292,16 @@ const deserializeAws_queryListImportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3292,18 +3333,19 @@ const deserializeAws_queryListStackInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "StackSetNotFoundException": case "com.amazonaws.cloudformation#StackSetNotFoundException": throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3335,15 +3377,16 @@ const deserializeAws_queryListStackResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3375,15 +3418,16 @@ const deserializeAws_queryListStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3415,8 +3459,7 @@ const deserializeAws_queryListStackSetOperationResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotFoundException": case "com.amazonaws.cloudformation#OperationNotFoundException": @@ -3426,10 +3469,12 @@ const deserializeAws_queryListStackSetOperationResultsCommandError = async ( throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3461,18 +3506,19 @@ const deserializeAws_queryListStackSetOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "StackSetNotFoundException": case "com.amazonaws.cloudformation#StackSetNotFoundException": throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3504,15 +3550,16 @@ const deserializeAws_queryListStackSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3544,18 +3591,19 @@ const deserializeAws_queryListTypeRegistrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3587,18 +3635,19 @@ const deserializeAws_queryListTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3630,18 +3679,19 @@ const deserializeAws_queryListTypeVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3673,8 +3723,7 @@ const deserializeAws_queryPublishTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -3684,10 +3733,12 @@ const deserializeAws_queryPublishTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3719,8 +3770,7 @@ const deserializeAws_queryRecordHandlerProgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateTransitionException": case "com.amazonaws.cloudformation#InvalidStateTransitionException": @@ -3730,10 +3780,12 @@ const deserializeAws_queryRecordHandlerProgressCommandError = async ( throw await deserializeAws_queryOperationStatusCheckFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3765,18 +3817,19 @@ const deserializeAws_queryRegisterPublisherCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3808,18 +3861,19 @@ const deserializeAws_queryRegisterTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": throw await deserializeAws_queryCFNRegistryExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3851,18 +3905,19 @@ const deserializeAws_queryRollbackStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TokenAlreadyExistsException": case "com.amazonaws.cloudformation#TokenAlreadyExistsException": throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3891,15 +3946,16 @@ const deserializeAws_querySetStackPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3931,8 +3987,7 @@ const deserializeAws_querySetTypeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -3942,10 +3997,12 @@ const deserializeAws_querySetTypeConfigurationCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3977,8 +4034,7 @@ const deserializeAws_querySetTypeDefaultVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -3988,10 +4044,12 @@ const deserializeAws_querySetTypeDefaultVersionCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4020,15 +4078,16 @@ const deserializeAws_querySignalResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4060,8 +4119,7 @@ const deserializeAws_queryStopStackSetOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -4074,10 +4132,12 @@ const deserializeAws_queryStopStackSetOperationCommandError = async ( throw await deserializeAws_queryStackSetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4109,8 +4169,7 @@ const deserializeAws_queryTestTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CFNRegistryException": case "com.amazonaws.cloudformation#CFNRegistryException": @@ -4120,10 +4179,12 @@ const deserializeAws_queryTestTypeCommandError = async ( throw await deserializeAws_queryTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4155,8 +4216,7 @@ const deserializeAws_queryUpdateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapabilitiesException": case "com.amazonaws.cloudformation#InsufficientCapabilitiesException": @@ -4166,10 +4226,12 @@ const deserializeAws_queryUpdateStackCommandError = async ( throw await deserializeAws_queryTokenAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4201,8 +4263,7 @@ const deserializeAws_queryUpdateStackInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -4224,10 +4285,12 @@ const deserializeAws_queryUpdateStackInstancesCommandError = async ( throw await deserializeAws_queryStaleRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4259,8 +4322,7 @@ const deserializeAws_queryUpdateStackSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudformation#InvalidOperationException": @@ -4282,10 +4344,12 @@ const deserializeAws_queryUpdateStackSetCommandError = async ( throw await deserializeAws_queryStaleRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4317,15 +4381,16 @@ const deserializeAws_queryUpdateTerminationProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4357,15 +4422,16 @@ const deserializeAws_queryValidateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10596,12 +10662,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-cloudfront/src/protocols/Aws_restXml.ts b/clients/client-cloudfront/src/protocols/Aws_restXml.ts index 2652e2a0dcb08..935c3737e3402 100644 --- a/clients/client-cloudfront/src/protocols/Aws_restXml.ts +++ b/clients/client-cloudfront/src/protocols/Aws_restXml.ts @@ -3645,8 +3645,7 @@ const deserializeAws_restXmlAssociateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -3665,10 +3664,12 @@ const deserializeAws_restXmlAssociateAliasCommandError = async ( throw await deserializeAws_restXmlTooManyDistributionCNAMEsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3707,8 +3708,7 @@ const deserializeAws_restXmlCreateCachePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -3736,10 +3736,12 @@ const deserializeAws_restXmlCreateCachePolicyCommandError = async ( throw await deserializeAws_restXmlTooManyQueryStringsInCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3778,8 +3780,7 @@ const deserializeAws_restXmlCreateCloudFrontOriginAccessIdentityCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudFrontOriginAccessIdentityAlreadyExists": case "com.amazonaws.cloudfront#CloudFrontOriginAccessIdentityAlreadyExists": @@ -3798,10 +3799,12 @@ const deserializeAws_restXmlCreateCloudFrontOriginAccessIdentityCommandError = a throw await deserializeAws_restXmlTooManyCloudFrontOriginAccessIdentitiesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3840,8 +3843,7 @@ const deserializeAws_restXmlCreateDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4034,10 +4036,12 @@ const deserializeAws_restXmlCreateDistributionCommandError = async ( throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4076,8 +4080,7 @@ const deserializeAws_restXmlCreateDistributionWithTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4273,10 +4276,12 @@ const deserializeAws_restXmlCreateDistributionWithTagsCommandError = async ( throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4315,8 +4320,7 @@ const deserializeAws_restXmlCreateFieldLevelEncryptionConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "FieldLevelEncryptionConfigAlreadyExists": case "com.amazonaws.cloudfront#FieldLevelEncryptionConfigAlreadyExists": @@ -4344,10 +4348,12 @@ const deserializeAws_restXmlCreateFieldLevelEncryptionConfigCommandError = async throw await deserializeAws_restXmlTooManyFieldLevelEncryptionQueryArgProfilesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4386,8 +4392,7 @@ const deserializeAws_restXmlCreateFieldLevelEncryptionProfileCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "FieldLevelEncryptionProfileAlreadyExists": case "com.amazonaws.cloudfront#FieldLevelEncryptionProfileAlreadyExists": @@ -4415,10 +4420,12 @@ const deserializeAws_restXmlCreateFieldLevelEncryptionProfileCommandError = asyn throw await deserializeAws_restXmlTooManyFieldLevelEncryptionProfilesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4457,8 +4464,7 @@ const deserializeAws_restXmlCreateFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "FunctionAlreadyExists": case "com.amazonaws.cloudfront#FunctionAlreadyExists": @@ -4477,10 +4483,12 @@ const deserializeAws_restXmlCreateFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4515,8 +4523,7 @@ const deserializeAws_restXmlCreateInvalidationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4541,10 +4548,12 @@ const deserializeAws_restXmlCreateInvalidationCommandError = async ( throw await deserializeAws_restXmlTooManyInvalidationsInProgressResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4583,8 +4592,7 @@ const deserializeAws_restXmlCreateKeyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -4600,10 +4608,12 @@ const deserializeAws_restXmlCreateKeyGroupCommandError = async ( throw await deserializeAws_restXmlTooManyPublicKeysInKeyGroupResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4634,8 +4644,7 @@ const deserializeAws_restXmlCreateMonitoringSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4648,10 +4657,12 @@ const deserializeAws_restXmlCreateMonitoringSubscriptionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4690,8 +4701,7 @@ const deserializeAws_restXmlCreateOriginRequestPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4719,10 +4729,12 @@ const deserializeAws_restXmlCreateOriginRequestPolicyCommandError = async ( throw await deserializeAws_restXmlTooManyQueryStringsInOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4761,8 +4773,7 @@ const deserializeAws_restXmlCreatePublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -4775,10 +4786,12 @@ const deserializeAws_restXmlCreatePublicKeyCommandError = async ( throw await deserializeAws_restXmlTooManyPublicKeysResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4811,8 +4824,7 @@ const deserializeAws_restXmlCreateRealtimeLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4828,10 +4840,12 @@ const deserializeAws_restXmlCreateRealtimeLogConfigCommandError = async ( throw await deserializeAws_restXmlTooManyRealtimeLogConfigsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4870,8 +4884,7 @@ const deserializeAws_restXmlCreateResponseHeadersPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4896,10 +4909,12 @@ const deserializeAws_restXmlCreateResponseHeadersPolicyCommandError = async ( throw await deserializeAws_restXmlTooManyResponseHeadersPoliciesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4938,8 +4953,7 @@ const deserializeAws_restXmlCreateStreamingDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -4979,10 +4993,12 @@ const deserializeAws_restXmlCreateStreamingDistributionCommandError = async ( throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5021,8 +5037,7 @@ const deserializeAws_restXmlCreateStreamingDistributionWithTagsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5065,10 +5080,12 @@ const deserializeAws_restXmlCreateStreamingDistributionWithTagsCommandError = as throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5097,8 +5114,7 @@ const deserializeAws_restXmlDeleteCachePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5120,10 +5136,12 @@ const deserializeAws_restXmlDeleteCachePolicyCommandError = async ( throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5152,8 +5170,7 @@ const deserializeAws_restXmlDeleteCloudFrontOriginAccessIdentityCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5172,10 +5189,12 @@ const deserializeAws_restXmlDeleteCloudFrontOriginAccessIdentityCommandError = a throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5204,8 +5223,7 @@ const deserializeAws_restXmlDeleteDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5224,10 +5242,12 @@ const deserializeAws_restXmlDeleteDistributionCommandError = async ( throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5256,8 +5276,7 @@ const deserializeAws_restXmlDeleteFieldLevelEncryptionConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5276,10 +5295,12 @@ const deserializeAws_restXmlDeleteFieldLevelEncryptionConfigCommandError = async throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5308,8 +5329,7 @@ const deserializeAws_restXmlDeleteFieldLevelEncryptionProfileCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5328,10 +5348,12 @@ const deserializeAws_restXmlDeleteFieldLevelEncryptionProfileCommandError = asyn throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5360,8 +5382,7 @@ const deserializeAws_restXmlDeleteFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "FunctionInUse": case "com.amazonaws.cloudfront#FunctionInUse": @@ -5380,10 +5401,12 @@ const deserializeAws_restXmlDeleteFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5412,8 +5435,7 @@ const deserializeAws_restXmlDeleteKeyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidIfMatchVersion": case "com.amazonaws.cloudfront#InvalidIfMatchVersion": @@ -5429,10 +5451,12 @@ const deserializeAws_restXmlDeleteKeyGroupCommandError = async ( throw await deserializeAws_restXmlResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5461,8 +5485,7 @@ const deserializeAws_restXmlDeleteMonitoringSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5475,10 +5498,12 @@ const deserializeAws_restXmlDeleteMonitoringSubscriptionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5507,8 +5532,7 @@ const deserializeAws_restXmlDeleteOriginRequestPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5530,10 +5554,12 @@ const deserializeAws_restXmlDeleteOriginRequestPolicyCommandError = async ( throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5562,8 +5588,7 @@ const deserializeAws_restXmlDeletePublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5582,10 +5607,12 @@ const deserializeAws_restXmlDeletePublicKeyCommandError = async ( throw await deserializeAws_restXmlPublicKeyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5614,8 +5641,7 @@ const deserializeAws_restXmlDeleteRealtimeLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5631,10 +5657,12 @@ const deserializeAws_restXmlDeleteRealtimeLogConfigCommandError = async ( throw await deserializeAws_restXmlRealtimeLogConfigInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5663,8 +5691,7 @@ const deserializeAws_restXmlDeleteResponseHeadersPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5686,10 +5713,12 @@ const deserializeAws_restXmlDeleteResponseHeadersPolicyCommandError = async ( throw await deserializeAws_restXmlResponseHeadersPolicyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5718,8 +5747,7 @@ const deserializeAws_restXmlDeleteStreamingDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5738,10 +5766,12 @@ const deserializeAws_restXmlDeleteStreamingDistributionCommandError = async ( throw await deserializeAws_restXmlStreamingDistributionNotDisabledResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5776,8 +5806,7 @@ const deserializeAws_restXmlDescribeFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchFunctionExists": case "com.amazonaws.cloudfront#NoSuchFunctionExists": @@ -5787,10 +5816,12 @@ const deserializeAws_restXmlDescribeFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5825,8 +5856,7 @@ const deserializeAws_restXmlGetCachePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5836,10 +5866,12 @@ const deserializeAws_restXmlGetCachePolicyCommandError = async ( throw await deserializeAws_restXmlNoSuchCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5874,8 +5906,7 @@ const deserializeAws_restXmlGetCachePolicyConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5885,10 +5916,12 @@ const deserializeAws_restXmlGetCachePolicyConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5923,8 +5956,7 @@ const deserializeAws_restXmlGetCloudFrontOriginAccessIdentityCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5934,10 +5966,12 @@ const deserializeAws_restXmlGetCloudFrontOriginAccessIdentityCommandError = asyn throw await deserializeAws_restXmlNoSuchCloudFrontOriginAccessIdentityResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5975,8 +6009,7 @@ const deserializeAws_restXmlGetCloudFrontOriginAccessIdentityConfigCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -5986,10 +6019,12 @@ const deserializeAws_restXmlGetCloudFrontOriginAccessIdentityConfigCommandError throw await deserializeAws_restXmlNoSuchCloudFrontOriginAccessIdentityResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6024,8 +6059,7 @@ const deserializeAws_restXmlGetDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6035,10 +6069,12 @@ const deserializeAws_restXmlGetDistributionCommandError = async ( throw await deserializeAws_restXmlNoSuchDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6073,8 +6109,7 @@ const deserializeAws_restXmlGetDistributionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6084,10 +6119,12 @@ const deserializeAws_restXmlGetDistributionConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6122,8 +6159,7 @@ const deserializeAws_restXmlGetFieldLevelEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6133,10 +6169,12 @@ const deserializeAws_restXmlGetFieldLevelEncryptionCommandError = async ( throw await deserializeAws_restXmlNoSuchFieldLevelEncryptionConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6171,8 +6209,7 @@ const deserializeAws_restXmlGetFieldLevelEncryptionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6182,10 +6219,12 @@ const deserializeAws_restXmlGetFieldLevelEncryptionConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchFieldLevelEncryptionConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6220,8 +6259,7 @@ const deserializeAws_restXmlGetFieldLevelEncryptionProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6231,10 +6269,12 @@ const deserializeAws_restXmlGetFieldLevelEncryptionProfileCommandError = async ( throw await deserializeAws_restXmlNoSuchFieldLevelEncryptionProfileResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6269,8 +6309,7 @@ const deserializeAws_restXmlGetFieldLevelEncryptionProfileConfigCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6280,10 +6319,12 @@ const deserializeAws_restXmlGetFieldLevelEncryptionProfileConfigCommandError = a throw await deserializeAws_restXmlNoSuchFieldLevelEncryptionProfileResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6322,8 +6363,7 @@ const deserializeAws_restXmlGetFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchFunctionExists": case "com.amazonaws.cloudfront#NoSuchFunctionExists": @@ -6333,10 +6373,12 @@ const deserializeAws_restXmlGetFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6367,8 +6409,7 @@ const deserializeAws_restXmlGetInvalidationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6381,10 +6422,12 @@ const deserializeAws_restXmlGetInvalidationCommandError = async ( throw await deserializeAws_restXmlNoSuchInvalidationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6419,18 +6462,19 @@ const deserializeAws_restXmlGetKeyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchResource": case "com.amazonaws.cloudfront#NoSuchResource": throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6465,18 +6509,19 @@ const deserializeAws_restXmlGetKeyGroupConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchResource": case "com.amazonaws.cloudfront#NoSuchResource": throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6507,8 +6552,7 @@ const deserializeAws_restXmlGetMonitoringSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6521,10 +6565,12 @@ const deserializeAws_restXmlGetMonitoringSubscriptionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6559,8 +6605,7 @@ const deserializeAws_restXmlGetOriginRequestPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6570,10 +6615,12 @@ const deserializeAws_restXmlGetOriginRequestPolicyCommandError = async ( throw await deserializeAws_restXmlNoSuchOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6608,8 +6655,7 @@ const deserializeAws_restXmlGetOriginRequestPolicyConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6619,10 +6665,12 @@ const deserializeAws_restXmlGetOriginRequestPolicyConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6657,8 +6705,7 @@ const deserializeAws_restXmlGetPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6668,10 +6715,12 @@ const deserializeAws_restXmlGetPublicKeyCommandError = async ( throw await deserializeAws_restXmlNoSuchPublicKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6706,8 +6755,7 @@ const deserializeAws_restXmlGetPublicKeyConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6717,10 +6765,12 @@ const deserializeAws_restXmlGetPublicKeyConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchPublicKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6753,8 +6803,7 @@ const deserializeAws_restXmlGetRealtimeLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6767,10 +6816,12 @@ const deserializeAws_restXmlGetRealtimeLogConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchRealtimeLogConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6805,8 +6856,7 @@ const deserializeAws_restXmlGetResponseHeadersPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6816,10 +6866,12 @@ const deserializeAws_restXmlGetResponseHeadersPolicyCommandError = async ( throw await deserializeAws_restXmlNoSuchResponseHeadersPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6854,8 +6906,7 @@ const deserializeAws_restXmlGetResponseHeadersPolicyConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6865,10 +6916,12 @@ const deserializeAws_restXmlGetResponseHeadersPolicyConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchResponseHeadersPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6903,8 +6956,7 @@ const deserializeAws_restXmlGetStreamingDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6914,10 +6966,12 @@ const deserializeAws_restXmlGetStreamingDistributionCommandError = async ( throw await deserializeAws_restXmlNoSuchStreamingDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6952,8 +7006,7 @@ const deserializeAws_restXmlGetStreamingDistributionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -6963,10 +7016,12 @@ const deserializeAws_restXmlGetStreamingDistributionConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchStreamingDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6997,8 +7052,7 @@ const deserializeAws_restXmlListCachePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7011,10 +7065,12 @@ const deserializeAws_restXmlListCachePoliciesCommandError = async ( throw await deserializeAws_restXmlNoSuchCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7045,18 +7101,19 @@ const deserializeAws_restXmlListCloudFrontOriginAccessIdentitiesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7087,8 +7144,7 @@ const deserializeAws_restXmlListConflictingAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -7098,10 +7154,12 @@ const deserializeAws_restXmlListConflictingAliasesCommandError = async ( throw await deserializeAws_restXmlNoSuchDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7132,18 +7190,19 @@ const deserializeAws_restXmlListDistributionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7174,8 +7233,7 @@ const deserializeAws_restXmlListDistributionsByCachePolicyIdCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7188,10 +7246,12 @@ const deserializeAws_restXmlListDistributionsByCachePolicyIdCommandError = async throw await deserializeAws_restXmlNoSuchCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7222,8 +7282,7 @@ const deserializeAws_restXmlListDistributionsByKeyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -7233,10 +7292,12 @@ const deserializeAws_restXmlListDistributionsByKeyGroupCommandError = async ( throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7267,8 +7328,7 @@ const deserializeAws_restXmlListDistributionsByOriginRequestPolicyIdCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7281,10 +7341,12 @@ const deserializeAws_restXmlListDistributionsByOriginRequestPolicyIdCommandError throw await deserializeAws_restXmlNoSuchOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7315,18 +7377,19 @@ const deserializeAws_restXmlListDistributionsByRealtimeLogConfigCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7357,8 +7420,7 @@ const deserializeAws_restXmlListDistributionsByResponseHeadersPolicyIdCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7371,10 +7433,12 @@ const deserializeAws_restXmlListDistributionsByResponseHeadersPolicyIdCommandErr throw await deserializeAws_restXmlNoSuchResponseHeadersPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7405,8 +7469,7 @@ const deserializeAws_restXmlListDistributionsByWebACLIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -7416,10 +7479,12 @@ const deserializeAws_restXmlListDistributionsByWebACLIdCommandError = async ( throw await deserializeAws_restXmlInvalidWebACLIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7450,18 +7515,19 @@ const deserializeAws_restXmlListFieldLevelEncryptionConfigsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7492,18 +7558,19 @@ const deserializeAws_restXmlListFieldLevelEncryptionProfilesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7534,8 +7601,7 @@ const deserializeAws_restXmlListFunctionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -7545,10 +7611,12 @@ const deserializeAws_restXmlListFunctionsCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7579,8 +7647,7 @@ const deserializeAws_restXmlListInvalidationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7593,10 +7660,12 @@ const deserializeAws_restXmlListInvalidationsCommandError = async ( throw await deserializeAws_restXmlNoSuchDistributionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7627,18 +7696,19 @@ const deserializeAws_restXmlListKeyGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7669,8 +7739,7 @@ const deserializeAws_restXmlListOriginRequestPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7683,10 +7752,12 @@ const deserializeAws_restXmlListOriginRequestPoliciesCommandError = async ( throw await deserializeAws_restXmlNoSuchOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7717,18 +7788,19 @@ const deserializeAws_restXmlListPublicKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7759,8 +7831,7 @@ const deserializeAws_restXmlListRealtimeLogConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7773,10 +7844,12 @@ const deserializeAws_restXmlListRealtimeLogConfigsCommandError = async ( throw await deserializeAws_restXmlNoSuchRealtimeLogConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7807,8 +7880,7 @@ const deserializeAws_restXmlListResponseHeadersPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7821,10 +7893,12 @@ const deserializeAws_restXmlListResponseHeadersPoliciesCommandError = async ( throw await deserializeAws_restXmlNoSuchResponseHeadersPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7855,18 +7929,19 @@ const deserializeAws_restXmlListStreamingDistributionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": throw await deserializeAws_restXmlInvalidArgumentResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7897,8 +7972,7 @@ const deserializeAws_restXmlListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -7914,10 +7988,12 @@ const deserializeAws_restXmlListTagsForResourceCommandError = async ( throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7948,8 +8024,7 @@ const deserializeAws_restXmlPublishFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -7968,10 +8043,12 @@ const deserializeAws_restXmlPublishFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8000,8 +8077,7 @@ const deserializeAws_restXmlTagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8017,10 +8093,12 @@ const deserializeAws_restXmlTagResourceCommandError = async ( throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8051,8 +8129,7 @@ const deserializeAws_restXmlTestFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -8071,10 +8148,12 @@ const deserializeAws_restXmlTestFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8103,8 +8182,7 @@ const deserializeAws_restXmlUntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8120,10 +8198,12 @@ const deserializeAws_restXmlUntagResourceCommandError = async ( throw await deserializeAws_restXmlNoSuchResourceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8158,8 +8238,7 @@ const deserializeAws_restXmlUpdateCachePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8196,10 +8275,12 @@ const deserializeAws_restXmlUpdateCachePolicyCommandError = async ( throw await deserializeAws_restXmlTooManyQueryStringsInCachePolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8234,8 +8315,7 @@ const deserializeAws_restXmlUpdateCloudFrontOriginAccessIdentityCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8263,10 +8343,12 @@ const deserializeAws_restXmlUpdateCloudFrontOriginAccessIdentityCommandError = a throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8301,8 +8383,7 @@ const deserializeAws_restXmlUpdateDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8495,10 +8576,12 @@ const deserializeAws_restXmlUpdateDistributionCommandError = async ( throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8533,8 +8616,7 @@ const deserializeAws_restXmlUpdateFieldLevelEncryptionConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8571,10 +8653,12 @@ const deserializeAws_restXmlUpdateFieldLevelEncryptionConfigCommandError = async throw await deserializeAws_restXmlTooManyFieldLevelEncryptionQueryArgProfilesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8609,8 +8693,7 @@ const deserializeAws_restXmlUpdateFieldLevelEncryptionProfileCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8650,10 +8733,12 @@ const deserializeAws_restXmlUpdateFieldLevelEncryptionProfileCommandError = asyn throw await deserializeAws_restXmlTooManyFieldLevelEncryptionFieldPatternsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8688,8 +8773,7 @@ const deserializeAws_restXmlUpdateFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "FunctionSizeLimitExceeded": case "com.amazonaws.cloudfront#FunctionSizeLimitExceeded": @@ -8711,10 +8795,12 @@ const deserializeAws_restXmlUpdateFunctionCommandError = async ( throw await deserializeAws_restXmlUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8749,8 +8835,7 @@ const deserializeAws_restXmlUpdateKeyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.cloudfront#InvalidArgument": @@ -8772,10 +8857,12 @@ const deserializeAws_restXmlUpdateKeyGroupCommandError = async ( throw await deserializeAws_restXmlTooManyPublicKeysInKeyGroupResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8810,8 +8897,7 @@ const deserializeAws_restXmlUpdateOriginRequestPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8848,10 +8934,12 @@ const deserializeAws_restXmlUpdateOriginRequestPolicyCommandError = async ( throw await deserializeAws_restXmlTooManyQueryStringsInOriginRequestPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8886,8 +8974,7 @@ const deserializeAws_restXmlUpdatePublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8912,10 +8999,12 @@ const deserializeAws_restXmlUpdatePublicKeyCommandError = async ( throw await deserializeAws_restXmlPreconditionFailedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8948,8 +9037,7 @@ const deserializeAws_restXmlUpdateRealtimeLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -8962,10 +9050,12 @@ const deserializeAws_restXmlUpdateRealtimeLogConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchRealtimeLogConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9000,8 +9090,7 @@ const deserializeAws_restXmlUpdateResponseHeadersPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -9035,10 +9124,12 @@ const deserializeAws_restXmlUpdateResponseHeadersPolicyCommandError = async ( throw await deserializeAws_restXmlTooManyCustomHeadersInResponseHeadersPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9073,8 +9164,7 @@ const deserializeAws_restXmlUpdateStreamingDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDenied": case "com.amazonaws.cloudfront#AccessDenied": @@ -9117,10 +9207,12 @@ const deserializeAws_restXmlUpdateStreamingDistributionCommandError = async ( throw await deserializeAws_restXmlTrustedSignerDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -17649,12 +17741,11 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => return {}; }); -const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-cloudhsm-v2/src/protocols/Aws_json1_1.ts b/clients/client-cloudhsm-v2/src/protocols/Aws_json1_1.ts index 8e74d53e3d0a6..f2c00c7b7e37c 100644 --- a/clients/client-cloudhsm-v2/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloudhsm-v2/src/protocols/Aws_json1_1.ts @@ -301,8 +301,7 @@ const deserializeAws_json1_1CopyBackupToRegionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -324,10 +323,12 @@ const deserializeAws_json1_1CopyBackupToRegionCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -359,8 +360,7 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -382,10 +382,12 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -417,8 +419,7 @@ const deserializeAws_json1_1CreateHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -437,10 +438,12 @@ const deserializeAws_json1_1CreateHsmCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -472,8 +475,7 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -492,10 +494,12 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -527,8 +531,7 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -550,10 +553,12 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -585,8 +590,7 @@ const deserializeAws_json1_1DeleteHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -605,10 +609,12 @@ const deserializeAws_json1_1DeleteHsmCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -640,8 +646,7 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -663,10 +668,12 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -698,8 +705,7 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -718,10 +724,12 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -753,8 +761,7 @@ const deserializeAws_json1_1InitializeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -773,10 +780,12 @@ const deserializeAws_json1_1InitializeClusterCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -808,8 +817,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -831,10 +839,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -866,8 +876,7 @@ const deserializeAws_json1_1ModifyBackupAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -886,10 +895,12 @@ const deserializeAws_json1_1ModifyBackupAttributesCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -921,8 +932,7 @@ const deserializeAws_json1_1ModifyClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -941,10 +951,12 @@ const deserializeAws_json1_1ModifyClusterCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -976,8 +988,7 @@ const deserializeAws_json1_1RestoreBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -996,10 +1007,12 @@ const deserializeAws_json1_1RestoreBackupCommandError = async ( throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1031,8 +1044,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -1054,10 +1066,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1089,8 +1103,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmAccessDeniedException": case "com.amazonaws.cloudhsmv2#CloudHsmAccessDeniedException": @@ -1112,10 +1125,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1CloudHsmTagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1822,7 +1837,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1848,6 +1863,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudhsm/src/protocols/Aws_json1_1.ts b/clients/client-cloudhsm/src/protocols/Aws_json1_1.ts index fd69df832316f..e00a583579d0e 100644 --- a/clients/client-cloudhsm/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloudhsm/src/protocols/Aws_json1_1.ts @@ -372,8 +372,7 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -386,10 +385,12 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -421,8 +422,7 @@ const deserializeAws_json1_1CreateHapgCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -435,10 +435,12 @@ const deserializeAws_json1_1CreateHapgCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -470,8 +472,7 @@ const deserializeAws_json1_1CreateHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -484,10 +485,12 @@ const deserializeAws_json1_1CreateHsmCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -519,8 +522,7 @@ const deserializeAws_json1_1CreateLunaClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -533,10 +535,12 @@ const deserializeAws_json1_1CreateLunaClientCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -568,8 +572,7 @@ const deserializeAws_json1_1DeleteHapgCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -582,10 +585,12 @@ const deserializeAws_json1_1DeleteHapgCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -617,8 +622,7 @@ const deserializeAws_json1_1DeleteHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -631,10 +635,12 @@ const deserializeAws_json1_1DeleteHsmCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -666,8 +672,7 @@ const deserializeAws_json1_1DeleteLunaClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -680,10 +685,12 @@ const deserializeAws_json1_1DeleteLunaClientCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -715,8 +722,7 @@ const deserializeAws_json1_1DescribeHapgCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -729,10 +735,12 @@ const deserializeAws_json1_1DescribeHapgCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -764,8 +772,7 @@ const deserializeAws_json1_1DescribeHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -778,10 +785,12 @@ const deserializeAws_json1_1DescribeHsmCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -813,8 +822,7 @@ const deserializeAws_json1_1DescribeLunaClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -827,10 +835,12 @@ const deserializeAws_json1_1DescribeLunaClientCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -862,8 +872,7 @@ const deserializeAws_json1_1GetConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -876,10 +885,12 @@ const deserializeAws_json1_1GetConfigCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +922,7 @@ const deserializeAws_json1_1ListAvailableZonesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -925,10 +935,12 @@ const deserializeAws_json1_1ListAvailableZonesCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -960,8 +972,7 @@ const deserializeAws_json1_1ListHapgsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -974,10 +985,12 @@ const deserializeAws_json1_1ListHapgsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1009,8 +1022,7 @@ const deserializeAws_json1_1ListHsmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1023,10 +1035,12 @@ const deserializeAws_json1_1ListHsmsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1058,8 +1072,7 @@ const deserializeAws_json1_1ListLunaClientsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1072,10 +1085,12 @@ const deserializeAws_json1_1ListLunaClientsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1107,8 +1122,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1121,10 +1135,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1156,8 +1172,7 @@ const deserializeAws_json1_1ModifyHapgCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1170,10 +1185,12 @@ const deserializeAws_json1_1ModifyHapgCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1205,8 +1222,7 @@ const deserializeAws_json1_1ModifyHsmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1219,10 +1235,12 @@ const deserializeAws_json1_1ModifyHsmCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,18 +1272,19 @@ const deserializeAws_json1_1ModifyLunaClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmServiceException": case "com.amazonaws.cloudhsm#CloudHsmServiceException": throw await deserializeAws_json1_1CloudHsmServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1297,8 +1316,7 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmInternalException": case "com.amazonaws.cloudhsm#CloudHsmInternalException": @@ -1311,10 +1329,12 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1964,7 +1984,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1990,6 +2010,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudsearch-domain/src/protocols/Aws_restJson1.ts b/clients/client-cloudsearch-domain/src/protocols/Aws_restJson1.ts index 694e400f64e17..f755539b48f6d 100644 --- a/clients/client-cloudsearch-domain/src/protocols/Aws_restJson1.ts +++ b/clients/client-cloudsearch-domain/src/protocols/Aws_restJson1.ts @@ -168,18 +168,19 @@ const deserializeAws_restJson1SearchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "SearchException": case "com.amazonaws.cloudsearchdomain#SearchException": throw await deserializeAws_restJson1SearchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -216,18 +217,19 @@ const deserializeAws_restJson1SuggestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "SearchException": case "com.amazonaws.cloudsearchdomain#SearchException": throw await deserializeAws_restJson1SearchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -272,18 +274,19 @@ const deserializeAws_restJson1UploadDocumentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentServiceException": case "com.amazonaws.cloudsearchdomain#DocumentServiceException": throw await deserializeAws_restJson1DocumentServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -585,7 +588,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -611,6 +614,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudsearch/src/protocols/Aws_query.ts b/clients/client-cloudsearch/src/protocols/Aws_query.ts index bbf68750fc654..2cbb546a4bbae 100644 --- a/clients/client-cloudsearch/src/protocols/Aws_query.ts +++ b/clients/client-cloudsearch/src/protocols/Aws_query.ts @@ -622,8 +622,7 @@ const deserializeAws_queryBuildSuggestersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -639,10 +638,12 @@ const deserializeAws_queryBuildSuggestersCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -674,8 +675,7 @@ const deserializeAws_queryCreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -694,10 +694,12 @@ const deserializeAws_queryCreateDomainCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -729,8 +731,7 @@ const deserializeAws_queryDefineAnalysisSchemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -752,10 +753,12 @@ const deserializeAws_queryDefineAnalysisSchemeCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -787,8 +790,7 @@ const deserializeAws_queryDefineExpressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -810,10 +812,12 @@ const deserializeAws_queryDefineExpressionCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -845,8 +849,7 @@ const deserializeAws_queryDefineIndexFieldCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -868,10 +871,12 @@ const deserializeAws_queryDefineIndexFieldCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -903,8 +908,7 @@ const deserializeAws_queryDefineSuggesterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -926,10 +930,12 @@ const deserializeAws_queryDefineSuggesterCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -961,8 +967,7 @@ const deserializeAws_queryDeleteAnalysisSchemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -981,10 +986,12 @@ const deserializeAws_queryDeleteAnalysisSchemeCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1016,8 +1023,7 @@ const deserializeAws_queryDeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1027,10 +1033,12 @@ const deserializeAws_queryDeleteDomainCommandError = async ( throw await deserializeAws_queryInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1062,8 +1070,7 @@ const deserializeAws_queryDeleteExpressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1082,10 +1089,12 @@ const deserializeAws_queryDeleteExpressionCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1117,8 +1126,7 @@ const deserializeAws_queryDeleteIndexFieldCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1137,10 +1145,12 @@ const deserializeAws_queryDeleteIndexFieldCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1172,8 +1182,7 @@ const deserializeAws_queryDeleteSuggesterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1192,10 +1201,12 @@ const deserializeAws_queryDeleteSuggesterCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1227,8 +1238,7 @@ const deserializeAws_queryDescribeAnalysisSchemesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1241,10 +1251,12 @@ const deserializeAws_queryDescribeAnalysisSchemesCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1276,8 +1288,7 @@ const deserializeAws_queryDescribeAvailabilityOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1299,10 +1310,12 @@ const deserializeAws_queryDescribeAvailabilityOptionsCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1337,8 +1350,7 @@ const deserializeAws_queryDescribeDomainEndpointOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1357,10 +1369,12 @@ const deserializeAws_queryDescribeDomainEndpointOptionsCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1392,8 +1406,7 @@ const deserializeAws_queryDescribeDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1403,10 +1416,12 @@ const deserializeAws_queryDescribeDomainsCommandError = async ( throw await deserializeAws_queryInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1438,8 +1453,7 @@ const deserializeAws_queryDescribeExpressionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1452,10 +1466,12 @@ const deserializeAws_queryDescribeExpressionsCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1487,8 +1503,7 @@ const deserializeAws_queryDescribeIndexFieldsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1501,10 +1516,12 @@ const deserializeAws_queryDescribeIndexFieldsCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1536,8 +1553,7 @@ const deserializeAws_queryDescribeScalingParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1550,10 +1566,12 @@ const deserializeAws_queryDescribeScalingParametersCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1588,8 +1606,7 @@ const deserializeAws_queryDescribeServiceAccessPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1602,10 +1619,12 @@ const deserializeAws_queryDescribeServiceAccessPoliciesCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1637,8 +1656,7 @@ const deserializeAws_queryDescribeSuggestersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1651,10 +1669,12 @@ const deserializeAws_queryDescribeSuggestersCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1686,8 +1706,7 @@ const deserializeAws_queryIndexDocumentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1703,10 +1722,12 @@ const deserializeAws_queryIndexDocumentsCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1738,18 +1759,19 @@ const deserializeAws_queryListDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": throw await deserializeAws_queryBaseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1781,8 +1803,7 @@ const deserializeAws_queryUpdateAvailabilityOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1807,10 +1828,12 @@ const deserializeAws_queryUpdateAvailabilityOptionsCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1842,8 +1865,7 @@ const deserializeAws_queryUpdateDomainEndpointOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1868,10 +1890,12 @@ const deserializeAws_queryUpdateDomainEndpointOptionsCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1903,8 +1927,7 @@ const deserializeAws_queryUpdateScalingParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1926,10 +1949,12 @@ const deserializeAws_queryUpdateScalingParametersCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1961,8 +1986,7 @@ const deserializeAws_queryUpdateServiceAccessPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.cloudsearch#BaseException": @@ -1984,10 +2008,12 @@ const deserializeAws_queryUpdateServiceAccessPoliciesCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4278,12 +4304,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-cloudtrail/src/protocols/Aws_json1_1.ts b/clients/client-cloudtrail/src/protocols/Aws_json1_1.ts index c10134444115e..eecbeaac6a006 100644 --- a/clients/client-cloudtrail/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloudtrail/src/protocols/Aws_json1_1.ts @@ -607,8 +607,7 @@ const deserializeAws_json1_1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailARNInvalidException": case "com.amazonaws.cloudtrail#CloudTrailARNInvalidException": @@ -648,10 +647,12 @@ const deserializeAws_json1_1AddTagsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -683,8 +684,7 @@ const deserializeAws_json1_1CancelQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.cloudtrail#ConflictException": @@ -715,10 +715,12 @@ const deserializeAws_json1_1CancelQueryCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -750,8 +752,7 @@ const deserializeAws_json1_1CreateEventDataStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailAccessNotEnabledException": case "com.amazonaws.cloudtrail#CloudTrailAccessNotEnabledException": @@ -794,10 +795,12 @@ const deserializeAws_json1_1CreateEventDataStoreCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -829,8 +832,7 @@ const deserializeAws_json1_1CreateTrailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailAccessNotEnabledException": case "com.amazonaws.cloudtrail#CloudTrailAccessNotEnabledException": @@ -924,10 +926,12 @@ const deserializeAws_json1_1CreateTrailCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,8 +963,7 @@ const deserializeAws_json1_1DeleteEventDataStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -991,10 +994,12 @@ const deserializeAws_json1_1DeleteEventDataStoreCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1026,8 +1031,7 @@ const deserializeAws_json1_1DeleteTrailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.cloudtrail#ConflictException": @@ -1058,10 +1062,12 @@ const deserializeAws_json1_1DeleteTrailCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1099,7 @@ const deserializeAws_json1_1DescribeQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -1119,10 +1124,12 @@ const deserializeAws_json1_1DescribeQueryCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1154,8 +1161,7 @@ const deserializeAws_json1_1DescribeTrailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTrailNameException": case "com.amazonaws.cloudtrail#InvalidTrailNameException": @@ -1168,10 +1174,12 @@ const deserializeAws_json1_1DescribeTrailsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1203,8 +1211,7 @@ const deserializeAws_json1_1GetEventDataStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -1223,10 +1230,12 @@ const deserializeAws_json1_1GetEventDataStoreCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1258,8 +1267,7 @@ const deserializeAws_json1_1GetEventSelectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTrailNameException": case "com.amazonaws.cloudtrail#InvalidTrailNameException": @@ -1275,10 +1283,12 @@ const deserializeAws_json1_1GetEventSelectorsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1310,8 +1320,7 @@ const deserializeAws_json1_1GetInsightSelectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsightNotEnabledException": case "com.amazonaws.cloudtrail#InsightNotEnabledException": @@ -1330,10 +1339,12 @@ const deserializeAws_json1_1GetInsightSelectorsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1365,8 +1376,7 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -1397,10 +1407,12 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1432,8 +1444,7 @@ const deserializeAws_json1_1GetTrailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTrailNameException": case "com.amazonaws.cloudtrail#InvalidTrailNameException": @@ -1449,10 +1460,12 @@ const deserializeAws_json1_1GetTrailCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1484,8 +1497,7 @@ const deserializeAws_json1_1GetTrailStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTrailNameException": case "com.amazonaws.cloudtrail#InvalidTrailNameException": @@ -1501,10 +1513,12 @@ const deserializeAws_json1_1GetTrailStatusCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1536,8 +1550,7 @@ const deserializeAws_json1_1ListEventDataStoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidMaxResultsException": case "com.amazonaws.cloudtrail#InvalidMaxResultsException": @@ -1553,10 +1566,12 @@ const deserializeAws_json1_1ListEventDataStoresCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1588,8 +1603,7 @@ const deserializeAws_json1_1ListPublicKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTimeRangeException": case "com.amazonaws.cloudtrail#InvalidTimeRangeException": @@ -1605,10 +1619,12 @@ const deserializeAws_json1_1ListPublicKeysCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1640,8 +1656,7 @@ const deserializeAws_json1_1ListQueriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -1675,10 +1690,12 @@ const deserializeAws_json1_1ListQueriesCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1710,8 +1727,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailARNInvalidException": case "com.amazonaws.cloudtrail#CloudTrailARNInvalidException": @@ -1742,10 +1758,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1777,8 +1795,7 @@ const deserializeAws_json1_1ListTrailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.cloudtrail#OperationNotPermittedException": @@ -1788,10 +1805,12 @@ const deserializeAws_json1_1ListTrailsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1823,8 +1842,7 @@ const deserializeAws_json1_1LookupEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEventCategoryException": case "com.amazonaws.cloudtrail#InvalidEventCategoryException": @@ -1849,10 +1867,12 @@ const deserializeAws_json1_1LookupEventsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1884,8 +1904,7 @@ const deserializeAws_json1_1PutEventSelectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientDependencyServiceAccessPermissionException": case "com.amazonaws.cloudtrail#InsufficientDependencyServiceAccessPermissionException": @@ -1916,10 +1935,12 @@ const deserializeAws_json1_1PutEventSelectorsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1951,8 +1972,7 @@ const deserializeAws_json1_1PutInsightSelectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientEncryptionPolicyException": case "com.amazonaws.cloudtrail#InsufficientEncryptionPolicyException": @@ -1989,10 +2009,12 @@ const deserializeAws_json1_1PutInsightSelectorsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2024,8 +2046,7 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailARNInvalidException": case "com.amazonaws.cloudtrail#CloudTrailARNInvalidException": @@ -2059,10 +2080,12 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2094,8 +2117,7 @@ const deserializeAws_json1_1RestoreEventDataStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailAccessNotEnabledException": case "com.amazonaws.cloudtrail#CloudTrailAccessNotEnabledException": @@ -2138,10 +2160,12 @@ const deserializeAws_json1_1RestoreEventDataStoreCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2173,8 +2197,7 @@ const deserializeAws_json1_1StartLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientDependencyServiceAccessPermissionException": case "com.amazonaws.cloudtrail#InsufficientDependencyServiceAccessPermissionException": @@ -2202,10 +2225,12 @@ const deserializeAws_json1_1StartLoggingCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2237,8 +2262,7 @@ const deserializeAws_json1_1StartQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventDataStoreARNInvalidException": case "com.amazonaws.cloudtrail#EventDataStoreARNInvalidException": @@ -2266,10 +2290,12 @@ const deserializeAws_json1_1StartQueryCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2301,8 +2327,7 @@ const deserializeAws_json1_1StopLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientDependencyServiceAccessPermissionException": case "com.amazonaws.cloudtrail#InsufficientDependencyServiceAccessPermissionException": @@ -2330,10 +2355,12 @@ const deserializeAws_json1_1StopLoggingCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2365,8 +2392,7 @@ const deserializeAws_json1_1UpdateEventDataStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailAccessNotEnabledException": case "com.amazonaws.cloudtrail#CloudTrailAccessNotEnabledException": @@ -2406,10 +2432,12 @@ const deserializeAws_json1_1UpdateEventDataStoreCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2441,8 +2469,7 @@ const deserializeAws_json1_1UpdateTrailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudTrailAccessNotEnabledException": case "com.amazonaws.cloudtrail#CloudTrailAccessNotEnabledException": @@ -2533,10 +2560,12 @@ const deserializeAws_json1_1UpdateTrailCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5262,7 +5291,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5288,6 +5317,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudwatch-events/src/protocols/Aws_json1_1.ts b/clients/client-cloudwatch-events/src/protocols/Aws_json1_1.ts index 8a9771ecfaad3..b9b64033ad0ca 100644 --- a/clients/client-cloudwatch-events/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloudwatch-events/src/protocols/Aws_json1_1.ts @@ -968,8 +968,7 @@ const deserializeAws_json1_1ActivateEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -988,10 +987,12 @@ const deserializeAws_json1_1ActivateEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1023,8 +1024,7 @@ const deserializeAws_json1_1CancelReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1040,10 +1040,12 @@ const deserializeAws_json1_1CancelReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1075,8 +1077,7 @@ const deserializeAws_json1_1CreateApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1092,10 +1093,12 @@ const deserializeAws_json1_1CreateApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1127,8 +1130,7 @@ const deserializeAws_json1_1CreateArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1150,10 +1152,12 @@ const deserializeAws_json1_1CreateArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1185,8 +1189,7 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1199,10 +1202,12 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1234,8 +1239,7 @@ const deserializeAws_json1_1CreateEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1260,10 +1264,12 @@ const deserializeAws_json1_1CreateEventBusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1295,8 +1301,7 @@ const deserializeAws_json1_1CreatePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1315,10 +1320,12 @@ const deserializeAws_json1_1CreatePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1347,8 +1354,7 @@ const deserializeAws_json1_1DeactivateEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1367,10 +1373,12 @@ const deserializeAws_json1_1DeactivateEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1402,8 +1410,7 @@ const deserializeAws_json1_1DeauthorizeConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1416,10 +1423,12 @@ const deserializeAws_json1_1DeauthorizeConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1451,8 +1460,7 @@ const deserializeAws_json1_1DeleteApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1465,10 +1473,12 @@ const deserializeAws_json1_1DeleteApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1500,8 +1510,7 @@ const deserializeAws_json1_1DeleteArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1514,10 +1523,12 @@ const deserializeAws_json1_1DeleteArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1549,8 +1560,7 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1563,10 +1573,12 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1595,8 +1607,7 @@ const deserializeAws_json1_1DeleteEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1606,10 +1617,12 @@ const deserializeAws_json1_1DeleteEventBusCommandError = async ( throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1638,8 +1651,7 @@ const deserializeAws_json1_1DeletePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1652,10 +1664,12 @@ const deserializeAws_json1_1DeletePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1684,8 +1698,7 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -1701,10 +1714,12 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1736,8 +1751,7 @@ const deserializeAws_json1_1DescribeApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1747,10 +1761,12 @@ const deserializeAws_json1_1DescribeApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1782,8 +1798,7 @@ const deserializeAws_json1_1DescribeArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1796,10 +1811,12 @@ const deserializeAws_json1_1DescribeArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1831,8 +1848,7 @@ const deserializeAws_json1_1DescribeConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1842,10 +1858,12 @@ const deserializeAws_json1_1DescribeConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1877,8 +1895,7 @@ const deserializeAws_json1_1DescribeEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1888,10 +1905,12 @@ const deserializeAws_json1_1DescribeEventBusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1923,8 +1942,7 @@ const deserializeAws_json1_1DescribeEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1937,10 +1955,12 @@ const deserializeAws_json1_1DescribeEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1972,8 +1992,7 @@ const deserializeAws_json1_1DescribePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -1986,10 +2005,12 @@ const deserializeAws_json1_1DescribePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2021,8 +2042,7 @@ const deserializeAws_json1_1DescribeReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2032,10 +2052,12 @@ const deserializeAws_json1_1DescribeReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2089,7 @@ const deserializeAws_json1_1DescribeRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2078,10 +2099,12 @@ const deserializeAws_json1_1DescribeRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2110,8 +2133,7 @@ const deserializeAws_json1_1DisableRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -2127,10 +2149,12 @@ const deserializeAws_json1_1DisableRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2159,8 +2183,7 @@ const deserializeAws_json1_1EnableRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -2176,10 +2199,12 @@ const deserializeAws_json1_1EnableRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2211,18 +2236,19 @@ const deserializeAws_json1_1ListApiDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2254,8 +2280,7 @@ const deserializeAws_json1_1ListArchivesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2265,10 +2290,12 @@ const deserializeAws_json1_1ListArchivesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2300,18 +2327,19 @@ const deserializeAws_json1_1ListConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2343,18 +2371,19 @@ const deserializeAws_json1_1ListEventBusesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2415,7 @@ const deserializeAws_json1_1ListEventSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2397,10 +2425,12 @@ const deserializeAws_json1_1ListEventSourcesCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2432,8 +2462,7 @@ const deserializeAws_json1_1ListPartnerEventSourceAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2446,10 +2475,12 @@ const deserializeAws_json1_1ListPartnerEventSourceAccountsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2481,8 +2512,7 @@ const deserializeAws_json1_1ListPartnerEventSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2492,10 +2522,12 @@ const deserializeAws_json1_1ListPartnerEventSourcesCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2527,18 +2559,19 @@ const deserializeAws_json1_1ListReplaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2570,8 +2603,7 @@ const deserializeAws_json1_1ListRuleNamesByTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2581,10 +2613,12 @@ const deserializeAws_json1_1ListRuleNamesByTargetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2616,8 +2650,7 @@ const deserializeAws_json1_1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2627,10 +2660,12 @@ const deserializeAws_json1_1ListRulesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2662,8 +2697,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2673,10 +2707,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2708,8 +2744,7 @@ const deserializeAws_json1_1ListTargetsByRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2719,10 +2754,12 @@ const deserializeAws_json1_1ListTargetsByRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2754,18 +2791,19 @@ const deserializeAws_json1_1PutEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2797,8 +2835,7 @@ const deserializeAws_json1_1PutPartnerEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -2808,10 +2845,12 @@ const deserializeAws_json1_1PutPartnerEventsCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2840,8 +2879,7 @@ const deserializeAws_json1_1PutPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -2860,10 +2898,12 @@ const deserializeAws_json1_1PutPermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2895,8 +2935,7 @@ const deserializeAws_json1_1PutRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -2918,10 +2957,12 @@ const deserializeAws_json1_1PutRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2994,7 @@ const deserializeAws_json1_1PutTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -2973,10 +3013,12 @@ const deserializeAws_json1_1PutTargetsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3005,8 +3047,7 @@ const deserializeAws_json1_1RemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3022,10 +3063,12 @@ const deserializeAws_json1_1RemovePermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3057,8 +3100,7 @@ const deserializeAws_json1_1RemoveTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3074,10 +3116,12 @@ const deserializeAws_json1_1RemoveTargetsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3109,8 +3153,7 @@ const deserializeAws_json1_1StartReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -3129,10 +3172,12 @@ const deserializeAws_json1_1StartReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3164,8 +3209,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3181,10 +3225,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3216,8 +3262,7 @@ const deserializeAws_json1_1TestEventPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.cloudwatchevents#InternalException": @@ -3227,10 +3272,12 @@ const deserializeAws_json1_1TestEventPatternCommandError = async ( throw await deserializeAws_json1_1InvalidEventPatternExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3262,8 +3309,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3279,10 +3325,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3314,8 +3362,7 @@ const deserializeAws_json1_1UpdateApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3331,10 +3378,12 @@ const deserializeAws_json1_1UpdateApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3366,8 +3415,7 @@ const deserializeAws_json1_1UpdateArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3386,10 +3434,12 @@ const deserializeAws_json1_1UpdateArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3421,8 +3471,7 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatchevents#ConcurrentModificationException": @@ -3438,10 +3487,12 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6588,7 +6639,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6614,6 +6665,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudwatch-logs/src/protocols/Aws_json1_1.ts b/clients/client-cloudwatch-logs/src/protocols/Aws_json1_1.ts index 3325611c183fd..8c187213be43d 100644 --- a/clients/client-cloudwatch-logs/src/protocols/Aws_json1_1.ts +++ b/clients/client-cloudwatch-logs/src/protocols/Aws_json1_1.ts @@ -767,8 +767,7 @@ const deserializeAws_json1_1AssociateKmsKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -784,10 +783,12 @@ const deserializeAws_json1_1AssociateKmsKeyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -816,8 +817,7 @@ const deserializeAws_json1_1CancelExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationException": case "com.amazonaws.cloudwatchlogs#InvalidOperationException": @@ -833,10 +833,12 @@ const deserializeAws_json1_1CancelExportTaskCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -868,8 +870,7 @@ const deserializeAws_json1_1CreateExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -891,10 +892,12 @@ const deserializeAws_json1_1CreateExportTaskCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -923,8 +926,7 @@ const deserializeAws_json1_1CreateLogGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -943,10 +945,12 @@ const deserializeAws_json1_1CreateLogGroupCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -975,8 +979,7 @@ const deserializeAws_json1_1CreateLogStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -992,10 +995,12 @@ const deserializeAws_json1_1CreateLogStreamCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1024,8 +1029,7 @@ const deserializeAws_json1_1DeleteDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1041,10 +1045,12 @@ const deserializeAws_json1_1DeleteDestinationCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1073,8 +1079,7 @@ const deserializeAws_json1_1DeleteLogGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1090,10 +1095,12 @@ const deserializeAws_json1_1DeleteLogGroupCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1122,8 +1129,7 @@ const deserializeAws_json1_1DeleteLogStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1139,10 +1145,12 @@ const deserializeAws_json1_1DeleteLogStreamCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1171,8 +1179,7 @@ const deserializeAws_json1_1DeleteMetricFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1188,10 +1195,12 @@ const deserializeAws_json1_1DeleteMetricFilterCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1223,8 +1232,7 @@ const deserializeAws_json1_1DeleteQueryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1237,10 +1245,12 @@ const deserializeAws_json1_1DeleteQueryDefinitionCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1269,8 +1279,7 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1283,10 +1292,12 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1315,8 +1326,7 @@ const deserializeAws_json1_1DeleteRetentionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1332,10 +1342,12 @@ const deserializeAws_json1_1DeleteRetentionPolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1364,8 +1376,7 @@ const deserializeAws_json1_1DeleteSubscriptionFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1381,10 +1392,12 @@ const deserializeAws_json1_1DeleteSubscriptionFilterCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1416,8 +1429,7 @@ const deserializeAws_json1_1DescribeDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1427,10 +1439,12 @@ const deserializeAws_json1_1DescribeDestinationsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1462,8 +1476,7 @@ const deserializeAws_json1_1DescribeExportTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1473,10 +1486,12 @@ const deserializeAws_json1_1DescribeExportTasksCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1508,8 +1523,7 @@ const deserializeAws_json1_1DescribeLogGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1519,10 +1533,12 @@ const deserializeAws_json1_1DescribeLogGroupsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1554,8 +1570,7 @@ const deserializeAws_json1_1DescribeLogStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1568,10 +1583,12 @@ const deserializeAws_json1_1DescribeLogStreamsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1620,7 @@ const deserializeAws_json1_1DescribeMetricFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1617,10 +1633,12 @@ const deserializeAws_json1_1DescribeMetricFiltersCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1652,8 +1670,7 @@ const deserializeAws_json1_1DescribeQueriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1666,10 +1683,12 @@ const deserializeAws_json1_1DescribeQueriesCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1701,8 +1720,7 @@ const deserializeAws_json1_1DescribeQueryDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1712,10 +1730,12 @@ const deserializeAws_json1_1DescribeQueryDefinitionsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1747,8 +1767,7 @@ const deserializeAws_json1_1DescribeResourcePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1758,10 +1777,12 @@ const deserializeAws_json1_1DescribeResourcePoliciesCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1793,8 +1814,7 @@ const deserializeAws_json1_1DescribeSubscriptionFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1807,10 +1827,12 @@ const deserializeAws_json1_1DescribeSubscriptionFiltersCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1839,8 +1861,7 @@ const deserializeAws_json1_1DisassociateKmsKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1856,10 +1877,12 @@ const deserializeAws_json1_1DisassociateKmsKeyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1891,8 +1914,7 @@ const deserializeAws_json1_1FilterLogEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1905,10 +1927,12 @@ const deserializeAws_json1_1FilterLogEventsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1940,8 +1964,7 @@ const deserializeAws_json1_1GetLogEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -1954,10 +1977,12 @@ const deserializeAws_json1_1GetLogEventsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1989,8 +2014,7 @@ const deserializeAws_json1_1GetLogGroupFieldsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2006,10 +2030,12 @@ const deserializeAws_json1_1GetLogGroupFieldsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2041,8 +2067,7 @@ const deserializeAws_json1_1GetLogRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2058,10 +2083,12 @@ const deserializeAws_json1_1GetLogRecordCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2093,8 +2120,7 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2107,10 +2133,12 @@ const deserializeAws_json1_1GetQueryResultsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2142,8 +2170,7 @@ const deserializeAws_json1_1ListTagsLogGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.cloudwatchlogs#ResourceNotFoundException": @@ -2153,10 +2180,12 @@ const deserializeAws_json1_1ListTagsLogGroupCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2188,8 +2217,7 @@ const deserializeAws_json1_1PutDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2202,10 +2230,12 @@ const deserializeAws_json1_1PutDestinationCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2234,8 +2264,7 @@ const deserializeAws_json1_1PutDestinationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2248,10 +2277,12 @@ const deserializeAws_json1_1PutDestinationPolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2283,8 +2314,7 @@ const deserializeAws_json1_1PutLogEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataAlreadyAcceptedException": case "com.amazonaws.cloudwatchlogs#DataAlreadyAcceptedException": @@ -2306,10 +2336,12 @@ const deserializeAws_json1_1PutLogEventsCommandError = async ( throw await deserializeAws_json1_1UnrecognizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2338,8 +2370,7 @@ const deserializeAws_json1_1PutMetricFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2358,10 +2389,12 @@ const deserializeAws_json1_1PutMetricFilterCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2393,8 +2426,7 @@ const deserializeAws_json1_1PutQueryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2410,10 +2442,12 @@ const deserializeAws_json1_1PutQueryDefinitionCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2445,8 +2479,7 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2459,10 +2492,12 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2491,8 +2526,7 @@ const deserializeAws_json1_1PutRetentionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2508,10 +2542,12 @@ const deserializeAws_json1_1PutRetentionPolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2540,8 +2576,7 @@ const deserializeAws_json1_1PutSubscriptionFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2560,10 +2595,12 @@ const deserializeAws_json1_1PutSubscriptionFilterCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2595,8 +2632,7 @@ const deserializeAws_json1_1StartQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2615,10 +2651,12 @@ const deserializeAws_json1_1StartQueryCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2650,8 +2688,7 @@ const deserializeAws_json1_1StopQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2664,10 +2701,12 @@ const deserializeAws_json1_1StopQueryCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2696,8 +2735,7 @@ const deserializeAws_json1_1TagLogGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2707,10 +2745,12 @@ const deserializeAws_json1_1TagLogGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2742,8 +2782,7 @@ const deserializeAws_json1_1TestMetricFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.cloudwatchlogs#InvalidParameterException": @@ -2753,10 +2792,12 @@ const deserializeAws_json1_1TestMetricFilterCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2785,18 +2826,19 @@ const deserializeAws_json1_1UntagLogGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.cloudwatchlogs#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4416,7 +4458,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4442,6 +4484,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cloudwatch/src/protocols/Aws_query.ts b/clients/client-cloudwatch/src/protocols/Aws_query.ts index ce9a21dd54246..309776eea0333 100644 --- a/clients/client-cloudwatch/src/protocols/Aws_query.ts +++ b/clients/client-cloudwatch/src/protocols/Aws_query.ts @@ -807,18 +807,19 @@ const deserializeAws_queryDeleteAlarmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.cloudwatch#ResourceNotFound": throw await deserializeAws_queryResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -850,8 +851,7 @@ const deserializeAws_queryDeleteAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -870,10 +870,12 @@ const deserializeAws_queryDeleteAnomalyDetectorCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -905,8 +907,7 @@ const deserializeAws_queryDeleteDashboardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DashboardNotFoundError": case "com.amazonaws.cloudwatch#DashboardNotFoundError": @@ -919,10 +920,12 @@ const deserializeAws_queryDeleteDashboardsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -954,8 +957,7 @@ const deserializeAws_queryDeleteInsightRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.cloudwatch#InvalidParameterValueException": @@ -965,10 +967,12 @@ const deserializeAws_queryDeleteInsightRulesCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1000,8 +1004,7 @@ const deserializeAws_queryDeleteMetricStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1014,10 +1017,12 @@ const deserializeAws_queryDeleteMetricStreamCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1049,18 +1054,19 @@ const deserializeAws_queryDescribeAlarmHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.cloudwatch#InvalidNextToken": throw await deserializeAws_queryInvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1092,18 +1098,19 @@ const deserializeAws_queryDescribeAlarmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.cloudwatch#InvalidNextToken": throw await deserializeAws_queryInvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1135,15 +1142,16 @@ const deserializeAws_queryDescribeAlarmsForMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1175,8 +1183,7 @@ const deserializeAws_queryDescribeAnomalyDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1192,10 +1199,12 @@ const deserializeAws_queryDescribeAnomalyDetectorsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1227,18 +1236,19 @@ const deserializeAws_queryDescribeInsightRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.cloudwatch#InvalidNextToken": throw await deserializeAws_queryInvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1267,15 +1277,16 @@ const deserializeAws_queryDisableAlarmActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1307,8 +1318,7 @@ const deserializeAws_queryDisableInsightRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.cloudwatch#InvalidParameterValueException": @@ -1318,10 +1328,12 @@ const deserializeAws_queryDisableInsightRulesCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1350,15 +1362,16 @@ const deserializeAws_queryEnableAlarmActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1390,8 +1403,7 @@ const deserializeAws_queryEnableInsightRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.cloudwatch#InvalidParameterValueException": @@ -1404,10 +1416,12 @@ const deserializeAws_queryEnableInsightRulesCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1439,8 +1453,7 @@ const deserializeAws_queryGetDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DashboardNotFoundError": case "com.amazonaws.cloudwatch#DashboardNotFoundError": @@ -1453,10 +1466,12 @@ const deserializeAws_queryGetDashboardCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1488,8 +1503,7 @@ const deserializeAws_queryGetInsightRuleReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.cloudwatch#InvalidParameterValueException": @@ -1502,10 +1516,12 @@ const deserializeAws_queryGetInsightRuleReportCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1537,18 +1553,19 @@ const deserializeAws_queryGetMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextToken": case "com.amazonaws.cloudwatch#InvalidNextToken": throw await deserializeAws_queryInvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1580,8 +1597,7 @@ const deserializeAws_queryGetMetricStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1597,10 +1613,12 @@ const deserializeAws_queryGetMetricStatisticsCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1632,8 +1650,7 @@ const deserializeAws_queryGetMetricStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1652,10 +1669,12 @@ const deserializeAws_queryGetMetricStreamCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1687,15 +1706,16 @@ const deserializeAws_queryGetMetricWidgetImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1727,8 +1747,7 @@ const deserializeAws_queryListDashboardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1738,10 +1757,12 @@ const deserializeAws_queryListDashboardsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1773,8 +1794,7 @@ const deserializeAws_queryListMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1784,10 +1804,12 @@ const deserializeAws_queryListMetricsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1819,8 +1841,7 @@ const deserializeAws_queryListMetricStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1836,10 +1857,12 @@ const deserializeAws_queryListMetricStreamsCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1871,8 +1894,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1885,10 +1907,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1920,8 +1944,7 @@ const deserializeAws_queryPutAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -1940,10 +1963,12 @@ const deserializeAws_queryPutAnomalyDetectorCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1972,18 +1997,19 @@ const deserializeAws_queryPutCompositeAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.cloudwatch#LimitExceededFault": throw await deserializeAws_queryLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2015,8 +2041,7 @@ const deserializeAws_queryPutDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DashboardInvalidInputError": case "com.amazonaws.cloudwatch#DashboardInvalidInputError": @@ -2026,10 +2051,12 @@ const deserializeAws_queryPutDashboardCommandError = async ( throw await deserializeAws_queryInternalServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2061,8 +2088,7 @@ const deserializeAws_queryPutInsightRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.cloudwatch#InvalidParameterValueException": @@ -2075,10 +2101,12 @@ const deserializeAws_queryPutInsightRuleCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2107,18 +2135,19 @@ const deserializeAws_queryPutMetricAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.cloudwatch#LimitExceededFault": throw await deserializeAws_queryLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2147,8 +2176,7 @@ const deserializeAws_queryPutMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -2164,10 +2192,12 @@ const deserializeAws_queryPutMetricDataCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2199,8 +2229,7 @@ const deserializeAws_queryPutMetricStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatch#ConcurrentModificationException": @@ -2219,10 +2248,12 @@ const deserializeAws_queryPutMetricStreamCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2251,8 +2282,7 @@ const deserializeAws_querySetAlarmStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidFormatFault": case "com.amazonaws.cloudwatch#InvalidFormatFault": @@ -2262,10 +2292,12 @@ const deserializeAws_querySetAlarmStateCommandError = async ( throw await deserializeAws_queryResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2297,8 +2329,7 @@ const deserializeAws_queryStartMetricStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -2311,10 +2342,12 @@ const deserializeAws_queryStartMetricStreamsCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2346,8 +2379,7 @@ const deserializeAws_queryStopMetricStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceFault": case "com.amazonaws.cloudwatch#InternalServiceFault": @@ -2360,10 +2392,12 @@ const deserializeAws_queryStopMetricStreamsCommandError = async ( throw await deserializeAws_queryMissingRequiredParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2395,8 +2429,7 @@ const deserializeAws_queryTagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatch#ConcurrentModificationException": @@ -2412,10 +2445,12 @@ const deserializeAws_queryTagResourceCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2447,8 +2482,7 @@ const deserializeAws_queryUntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cloudwatch#ConcurrentModificationException": @@ -2464,10 +2498,12 @@ const deserializeAws_queryUntagResourceCommandError = async ( throw await deserializeAws_queryResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6056,12 +6092,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-codeartifact/src/protocols/Aws_restJson1.ts b/clients/client-codeartifact/src/protocols/Aws_restJson1.ts index d19a64c85c40c..f73127a94ac1d 100644 --- a/clients/client-codeartifact/src/protocols/Aws_restJson1.ts +++ b/clients/client-codeartifact/src/protocols/Aws_restJson1.ts @@ -1187,8 +1187,7 @@ const deserializeAws_restJson1AssociateExternalConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1213,10 +1212,12 @@ const deserializeAws_restJson1AssociateExternalConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1256,8 +1257,7 @@ const deserializeAws_restJson1CopyPackageVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1282,10 +1282,12 @@ const deserializeAws_restJson1CopyPackageVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1318,8 +1320,7 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1344,10 +1345,12 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1380,8 +1383,7 @@ const deserializeAws_restJson1CreateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1406,10 +1408,12 @@ const deserializeAws_restJson1CreateRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1442,8 +1446,7 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1462,10 +1465,12 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1498,8 +1503,7 @@ const deserializeAws_restJson1DeleteDomainPermissionsPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1521,10 +1525,12 @@ const deserializeAws_restJson1DeleteDomainPermissionsPolicyCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1564,8 +1570,7 @@ const deserializeAws_restJson1DeletePackageVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1587,10 +1592,12 @@ const deserializeAws_restJson1DeletePackageVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1623,8 +1630,7 @@ const deserializeAws_restJson1DeleteRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1646,10 +1652,12 @@ const deserializeAws_restJson1DeleteRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1682,8 +1690,7 @@ const deserializeAws_restJson1DeleteRepositoryPermissionsPolicyCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1705,10 +1712,12 @@ const deserializeAws_restJson1DeleteRepositoryPermissionsPolicyCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1741,8 +1750,7 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1761,10 +1769,12 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1797,8 +1807,7 @@ const deserializeAws_restJson1DescribePackageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1820,10 +1829,12 @@ const deserializeAws_restJson1DescribePackageVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1856,8 +1867,7 @@ const deserializeAws_restJson1DescribeRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1876,10 +1886,12 @@ const deserializeAws_restJson1DescribeRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1912,8 +1924,7 @@ const deserializeAws_restJson1DisassociateExternalConnectionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -1938,10 +1949,12 @@ const deserializeAws_restJson1DisassociateExternalConnectionCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1981,8 +1994,7 @@ const deserializeAws_restJson1DisposePackageVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2004,10 +2016,12 @@ const deserializeAws_restJson1DisposePackageVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,8 +2058,7 @@ const deserializeAws_restJson1GetAuthorizationTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2064,10 +2077,12 @@ const deserializeAws_restJson1GetAuthorizationTokenCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2100,8 +2115,7 @@ const deserializeAws_restJson1GetDomainPermissionsPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2120,10 +2134,12 @@ const deserializeAws_restJson1GetDomainPermissionsPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2166,8 +2182,7 @@ const deserializeAws_restJson1GetPackageVersionAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2189,10 +2204,12 @@ const deserializeAws_restJson1GetPackageVersionAssetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2245,8 +2262,7 @@ const deserializeAws_restJson1GetPackageVersionReadmeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2265,10 +2281,12 @@ const deserializeAws_restJson1GetPackageVersionReadmeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2301,8 +2319,7 @@ const deserializeAws_restJson1GetRepositoryEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2321,10 +2338,12 @@ const deserializeAws_restJson1GetRepositoryEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2357,8 +2376,7 @@ const deserializeAws_restJson1GetRepositoryPermissionsPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2377,10 +2395,12 @@ const deserializeAws_restJson1GetRepositoryPermissionsPolicyCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2417,8 +2437,7 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2434,10 +2453,12 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2474,8 +2495,7 @@ const deserializeAws_restJson1ListPackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2494,10 +2514,12 @@ const deserializeAws_restJson1ListPackagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2554,8 +2576,7 @@ const deserializeAws_restJson1ListPackageVersionAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2574,10 +2595,12 @@ const deserializeAws_restJson1ListPackageVersionAssetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2634,8 +2657,7 @@ const deserializeAws_restJson1ListPackageVersionDependenciesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2654,10 +2676,12 @@ const deserializeAws_restJson1ListPackageVersionDependenciesCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2710,8 +2734,7 @@ const deserializeAws_restJson1ListPackageVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2730,10 +2753,12 @@ const deserializeAws_restJson1ListPackageVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2770,8 +2795,7 @@ const deserializeAws_restJson1ListRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2787,10 +2811,12 @@ const deserializeAws_restJson1ListRepositoriesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2827,8 +2853,7 @@ const deserializeAws_restJson1ListRepositoriesInDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2847,10 +2872,12 @@ const deserializeAws_restJson1ListRepositoriesInDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2883,8 +2910,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2900,10 +2926,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2936,8 +2964,7 @@ const deserializeAws_restJson1PutDomainPermissionsPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -2962,10 +2989,12 @@ const deserializeAws_restJson1PutDomainPermissionsPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2998,8 +3027,7 @@ const deserializeAws_restJson1PutRepositoryPermissionsPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -3024,10 +3052,12 @@ const deserializeAws_restJson1PutRepositoryPermissionsPolicyCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3056,8 +3086,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -3076,10 +3105,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3108,8 +3139,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -3125,10 +3155,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3168,8 +3200,7 @@ const deserializeAws_restJson1UpdatePackageVersionsStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -3191,10 +3222,12 @@ const deserializeAws_restJson1UpdatePackageVersionsStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3227,8 +3260,7 @@ const deserializeAws_restJson1UpdateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codeartifact#AccessDeniedException": @@ -3253,10 +3285,12 @@ const deserializeAws_restJson1UpdateRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3864,7 +3898,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3890,6 +3924,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codebuild/src/protocols/Aws_json1_1.ts b/clients/client-codebuild/src/protocols/Aws_json1_1.ts index e06f80cc373f3..5e7f2b5af79c5 100644 --- a/clients/client-codebuild/src/protocols/Aws_json1_1.ts +++ b/clients/client-codebuild/src/protocols/Aws_json1_1.ts @@ -873,18 +873,19 @@ const deserializeAws_json1_1BatchDeleteBuildsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -916,18 +917,19 @@ const deserializeAws_json1_1BatchGetBuildBatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,18 +961,19 @@ const deserializeAws_json1_1BatchGetBuildsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1002,18 +1005,19 @@ const deserializeAws_json1_1BatchGetProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1045,18 +1049,19 @@ const deserializeAws_json1_1BatchGetReportGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1088,18 +1093,19 @@ const deserializeAws_json1_1BatchGetReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1131,8 +1137,7 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountLimitExceededException": case "com.amazonaws.codebuild#AccountLimitExceededException": @@ -1145,10 +1150,12 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1180,8 +1187,7 @@ const deserializeAws_json1_1CreateReportGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountLimitExceededException": case "com.amazonaws.codebuild#AccountLimitExceededException": @@ -1194,10 +1200,12 @@ const deserializeAws_json1_1CreateReportGroupCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1229,8 +1237,7 @@ const deserializeAws_json1_1CreateWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1246,10 +1253,12 @@ const deserializeAws_json1_1CreateWebhookCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1281,18 +1290,19 @@ const deserializeAws_json1_1DeleteBuildBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1324,18 +1334,19 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1367,18 +1378,19 @@ const deserializeAws_json1_1DeleteReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1410,18 +1422,19 @@ const deserializeAws_json1_1DeleteReportGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,18 +1466,19 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1496,8 +1510,7 @@ const deserializeAws_json1_1DeleteSourceCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1507,10 +1520,12 @@ const deserializeAws_json1_1DeleteSourceCredentialsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1542,8 +1557,7 @@ const deserializeAws_json1_1DeleteWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1556,10 +1570,12 @@ const deserializeAws_json1_1DeleteWebhookCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1591,18 +1607,19 @@ const deserializeAws_json1_1DescribeCodeCoveragesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1634,8 +1651,7 @@ const deserializeAws_json1_1DescribeTestCasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1645,10 +1661,12 @@ const deserializeAws_json1_1DescribeTestCasesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1680,8 +1698,7 @@ const deserializeAws_json1_1GetReportGroupTrendCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1691,10 +1708,12 @@ const deserializeAws_json1_1GetReportGroupTrendCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1726,8 +1745,7 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1737,10 +1755,12 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1772,8 +1792,7 @@ const deserializeAws_json1_1ImportSourceCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountLimitExceededException": case "com.amazonaws.codebuild#AccountLimitExceededException": @@ -1786,10 +1805,12 @@ const deserializeAws_json1_1ImportSourceCredentialsCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1821,8 +1842,7 @@ const deserializeAws_json1_1InvalidateProjectCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1832,10 +1852,12 @@ const deserializeAws_json1_1InvalidateProjectCacheCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1867,18 +1889,19 @@ const deserializeAws_json1_1ListBuildBatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1910,8 +1933,7 @@ const deserializeAws_json1_1ListBuildBatchesForProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -1921,10 +1943,12 @@ const deserializeAws_json1_1ListBuildBatchesForProjectCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1956,18 +1980,19 @@ const deserializeAws_json1_1ListBuildsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1999,8 +2024,7 @@ const deserializeAws_json1_1ListBuildsForProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2010,10 +2034,12 @@ const deserializeAws_json1_1ListBuildsForProjectCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,15 +2071,16 @@ const deserializeAws_json1_1ListCuratedEnvironmentImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2085,18 +2112,19 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2128,18 +2156,19 @@ const deserializeAws_json1_1ListReportGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2171,18 +2200,19 @@ const deserializeAws_json1_1ListReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2214,8 +2244,7 @@ const deserializeAws_json1_1ListReportsForReportGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2225,10 +2254,12 @@ const deserializeAws_json1_1ListReportsForReportGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2260,18 +2291,19 @@ const deserializeAws_json1_1ListSharedProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2303,18 +2335,19 @@ const deserializeAws_json1_1ListSharedReportGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2346,18 +2379,19 @@ const deserializeAws_json1_1ListSourceCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2389,8 +2423,7 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2400,10 +2433,12 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2435,8 +2470,7 @@ const deserializeAws_json1_1RetryBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountLimitExceededException": case "com.amazonaws.codebuild#AccountLimitExceededException": @@ -2449,10 +2483,12 @@ const deserializeAws_json1_1RetryBuildCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2484,8 +2520,7 @@ const deserializeAws_json1_1RetryBuildBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2495,10 +2530,12 @@ const deserializeAws_json1_1RetryBuildBatchCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2530,8 +2567,7 @@ const deserializeAws_json1_1StartBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountLimitExceededException": case "com.amazonaws.codebuild#AccountLimitExceededException": @@ -2544,10 +2580,12 @@ const deserializeAws_json1_1StartBuildCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2579,8 +2617,7 @@ const deserializeAws_json1_1StartBuildBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2590,10 +2627,12 @@ const deserializeAws_json1_1StartBuildBatchCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2625,8 +2664,7 @@ const deserializeAws_json1_1StopBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2636,10 +2674,12 @@ const deserializeAws_json1_1StopBuildCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2671,8 +2711,7 @@ const deserializeAws_json1_1StopBuildBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2682,10 +2721,12 @@ const deserializeAws_json1_1StopBuildBatchCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2717,8 +2758,7 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2728,10 +2768,12 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2763,8 +2805,7 @@ const deserializeAws_json1_1UpdateProjectVisibilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2774,10 +2815,12 @@ const deserializeAws_json1_1UpdateProjectVisibilityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2809,8 +2852,7 @@ const deserializeAws_json1_1UpdateReportGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2820,10 +2862,12 @@ const deserializeAws_json1_1UpdateReportGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2855,8 +2899,7 @@ const deserializeAws_json1_1UpdateWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.codebuild#InvalidInputException": @@ -2869,10 +2912,12 @@ const deserializeAws_json1_1UpdateWebhookCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6012,7 +6057,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6038,6 +6083,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codecommit/src/protocols/Aws_json1_1.ts b/clients/client-codecommit/src/protocols/Aws_json1_1.ts index 5724543a6ecfe..df39eca437f39 100644 --- a/clients/client-codecommit/src/protocols/Aws_json1_1.ts +++ b/clients/client-codecommit/src/protocols/Aws_json1_1.ts @@ -1655,8 +1655,7 @@ const deserializeAws_json1_1AssociateApprovalRuleTemplateWithRepositoryCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -1699,10 +1698,12 @@ const deserializeAws_json1_1AssociateApprovalRuleTemplateWithRepositoryCommandEr throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1734,8 +1735,7 @@ const deserializeAws_json1_1BatchAssociateApprovalRuleTemplateWithRepositoriesCo body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -1769,10 +1769,12 @@ const deserializeAws_json1_1BatchAssociateApprovalRuleTemplateWithRepositoriesCo throw await deserializeAws_json1_1RepositoryNamesRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1804,8 +1806,7 @@ const deserializeAws_json1_1BatchDescribeMergeConflictsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -1872,10 +1873,12 @@ const deserializeAws_json1_1BatchDescribeMergeConflictsCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1907,8 +1910,7 @@ const deserializeAws_json1_1BatchDisassociateApprovalRuleTemplateFromRepositorie body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -1942,10 +1944,12 @@ const deserializeAws_json1_1BatchDisassociateApprovalRuleTemplateFromRepositorie throw await deserializeAws_json1_1RepositoryNamesRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1981,7 @@ const deserializeAws_json1_1BatchGetCommitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitIdsLimitExceededException": case "com.amazonaws.codecommit#CommitIdsLimitExceededException": @@ -2012,10 +2015,12 @@ const deserializeAws_json1_1BatchGetCommitsCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2047,8 +2052,7 @@ const deserializeAws_json1_1BatchGetRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -2076,10 +2080,12 @@ const deserializeAws_json1_1BatchGetRepositoriesCommandError = async ( throw await deserializeAws_json1_1RepositoryNamesRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2111,8 +2117,7 @@ const deserializeAws_json1_1CreateApprovalRuleTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateContentRequiredException": case "com.amazonaws.codecommit#ApprovalRuleTemplateContentRequiredException": @@ -2137,10 +2142,12 @@ const deserializeAws_json1_1CreateApprovalRuleTemplateCommandError = async ( throw await deserializeAws_json1_1NumberOfRuleTemplatesExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2169,8 +2176,7 @@ const deserializeAws_json1_1CreateBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchNameExistsException": case "com.amazonaws.codecommit#BranchNameExistsException": @@ -2216,10 +2222,12 @@ const deserializeAws_json1_1CreateBranchCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2259,7 @@ const deserializeAws_json1_1CreateCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -2370,10 +2377,12 @@ const deserializeAws_json1_1CreateCommitCommandError = async ( throw await deserializeAws_json1_1SourceFileOrContentRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2405,8 +2414,7 @@ const deserializeAws_json1_1CreatePullRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientRequestTokenRequiredException": case "com.amazonaws.codecommit#ClientRequestTokenRequiredException": @@ -2485,10 +2493,12 @@ const deserializeAws_json1_1CreatePullRequestCommandError = async ( throw await deserializeAws_json1_1TitleRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2520,8 +2530,7 @@ const deserializeAws_json1_1CreatePullRequestApprovalRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleContentRequiredException": case "com.amazonaws.codecommit#ApprovalRuleContentRequiredException": @@ -2570,10 +2579,12 @@ const deserializeAws_json1_1CreatePullRequestApprovalRuleCommandError = async ( throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2605,8 +2616,7 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -2652,10 +2662,12 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2687,8 +2699,7 @@ const deserializeAws_json1_1CreateUnreferencedMergeCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -2803,10 +2814,12 @@ const deserializeAws_json1_1CreateUnreferencedMergeCommitCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2838,8 +2851,7 @@ const deserializeAws_json1_1DeleteApprovalRuleTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateInUseException": case "com.amazonaws.codecommit#ApprovalRuleTemplateInUseException": @@ -2852,10 +2864,12 @@ const deserializeAws_json1_1DeleteApprovalRuleTemplateCommandError = async ( throw await deserializeAws_json1_1InvalidApprovalRuleTemplateNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2887,8 +2901,7 @@ const deserializeAws_json1_1DeleteBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchNameRequiredException": case "com.amazonaws.codecommit#BranchNameRequiredException": @@ -2925,10 +2938,12 @@ const deserializeAws_json1_1DeleteBranchCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2960,8 +2975,7 @@ const deserializeAws_json1_1DeleteCommentContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommentDeletedException": case "com.amazonaws.codecommit#CommentDeletedException": @@ -2977,10 +2991,12 @@ const deserializeAws_json1_1DeleteCommentContentCommandError = async ( throw await deserializeAws_json1_1InvalidCommentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3012,8 +3028,7 @@ const deserializeAws_json1_1DeleteFileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -3083,10 +3098,12 @@ const deserializeAws_json1_1DeleteFileCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3118,8 +3135,7 @@ const deserializeAws_json1_1DeletePullRequestApprovalRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleNameRequiredException": case "com.amazonaws.codecommit#ApprovalRuleNameRequiredException": @@ -3159,10 +3175,12 @@ const deserializeAws_json1_1DeletePullRequestApprovalRuleCommandError = async ( throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3194,8 +3212,7 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -3220,10 +3237,12 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3255,8 +3274,7 @@ const deserializeAws_json1_1DescribeMergeConflictsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -3329,10 +3347,12 @@ const deserializeAws_json1_1DescribeMergeConflictsCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3364,8 +3384,7 @@ const deserializeAws_json1_1DescribePullRequestEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActorDoesNotExistException": case "com.amazonaws.codecommit#ActorDoesNotExistException": @@ -3408,10 +3427,12 @@ const deserializeAws_json1_1DescribePullRequestEventsCommandError = async ( throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3440,8 +3461,7 @@ const deserializeAws_json1_1DisassociateApprovalRuleTemplateFromRepositoryComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -3478,10 +3498,12 @@ const deserializeAws_json1_1DisassociateApprovalRuleTemplateFromRepositoryComman throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3513,8 +3535,7 @@ const deserializeAws_json1_1EvaluatePullRequestApprovalRulesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -3551,10 +3572,12 @@ const deserializeAws_json1_1EvaluatePullRequestApprovalRulesCommandError = async throw await deserializeAws_json1_1RevisionNotCurrentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3586,8 +3609,7 @@ const deserializeAws_json1_1GetApprovalRuleTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -3600,10 +3622,12 @@ const deserializeAws_json1_1GetApprovalRuleTemplateCommandError = async ( throw await deserializeAws_json1_1InvalidApprovalRuleTemplateNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3635,8 +3659,7 @@ const deserializeAws_json1_1GetBlobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BlobIdDoesNotExistException": case "com.amazonaws.codecommit#BlobIdDoesNotExistException": @@ -3676,10 +3699,12 @@ const deserializeAws_json1_1GetBlobCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3711,8 +3736,7 @@ const deserializeAws_json1_1GetBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -3749,10 +3773,12 @@ const deserializeAws_json1_1GetBranchCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3784,8 +3810,7 @@ const deserializeAws_json1_1GetCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommentDeletedException": case "com.amazonaws.codecommit#CommentDeletedException": @@ -3816,10 +3841,12 @@ const deserializeAws_json1_1GetCommentCommandError = async ( throw await deserializeAws_json1_1InvalidCommentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3851,8 +3878,7 @@ const deserializeAws_json1_1GetCommentReactionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommentDeletedException": case "com.amazonaws.codecommit#CommentDeletedException": @@ -3877,10 +3903,12 @@ const deserializeAws_json1_1GetCommentReactionsCommandError = async ( throw await deserializeAws_json1_1InvalidReactionUserArnExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3912,8 +3940,7 @@ const deserializeAws_json1_1GetCommentsForComparedCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -3956,10 +3983,12 @@ const deserializeAws_json1_1GetCommentsForComparedCommitCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3991,8 +4020,7 @@ const deserializeAws_json1_1GetCommentsForPullRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4047,10 +4075,12 @@ const deserializeAws_json1_1GetCommentsForPullRequestCommandError = async ( throw await deserializeAws_json1_1RepositoryNotAssociatedWithPullRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4082,8 +4112,7 @@ const deserializeAws_json1_1GetCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitIdDoesNotExistException": case "com.amazonaws.codecommit#CommitIdDoesNotExistException": @@ -4120,10 +4149,12 @@ const deserializeAws_json1_1GetCommitCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4155,8 +4186,7 @@ const deserializeAws_json1_1GetDifferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4208,10 +4238,12 @@ const deserializeAws_json1_1GetDifferencesCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4243,8 +4275,7 @@ const deserializeAws_json1_1GetFileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4290,10 +4321,12 @@ const deserializeAws_json1_1GetFileCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4325,8 +4358,7 @@ const deserializeAws_json1_1GetFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4369,10 +4401,12 @@ const deserializeAws_json1_1GetFolderCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4404,8 +4438,7 @@ const deserializeAws_json1_1GetMergeCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4448,10 +4481,12 @@ const deserializeAws_json1_1GetMergeCommitCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4483,8 +4518,7 @@ const deserializeAws_json1_1GetMergeConflictsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4554,10 +4588,12 @@ const deserializeAws_json1_1GetMergeConflictsCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4589,8 +4625,7 @@ const deserializeAws_json1_1GetMergeOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitDoesNotExistException": case "com.amazonaws.codecommit#CommitDoesNotExistException": @@ -4642,10 +4677,12 @@ const deserializeAws_json1_1GetMergeOptionsCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4677,8 +4714,7 @@ const deserializeAws_json1_1GetPullRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -4706,10 +4742,12 @@ const deserializeAws_json1_1GetPullRequestCommandError = async ( throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4741,8 +4779,7 @@ const deserializeAws_json1_1GetPullRequestApprovalStatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -4776,10 +4813,12 @@ const deserializeAws_json1_1GetPullRequestApprovalStatesCommandError = async ( throw await deserializeAws_json1_1RevisionIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4811,8 +4850,7 @@ const deserializeAws_json1_1GetPullRequestOverrideStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -4846,10 +4884,12 @@ const deserializeAws_json1_1GetPullRequestOverrideStateCommandError = async ( throw await deserializeAws_json1_1RevisionIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4881,8 +4921,7 @@ const deserializeAws_json1_1GetRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -4910,10 +4949,12 @@ const deserializeAws_json1_1GetRepositoryCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4945,8 +4986,7 @@ const deserializeAws_json1_1GetRepositoryTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -4974,10 +5014,12 @@ const deserializeAws_json1_1GetRepositoryTriggersCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5009,8 +5051,7 @@ const deserializeAws_json1_1ListApprovalRuleTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidContinuationTokenException": case "com.amazonaws.codecommit#InvalidContinuationTokenException": @@ -5020,10 +5061,12 @@ const deserializeAws_json1_1ListApprovalRuleTemplatesCommandError = async ( throw await deserializeAws_json1_1InvalidMaxResultsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5055,8 +5098,7 @@ const deserializeAws_json1_1ListAssociatedApprovalRuleTemplatesForRepositoryComm body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -5090,10 +5132,12 @@ const deserializeAws_json1_1ListAssociatedApprovalRuleTemplatesForRepositoryComm throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5125,8 +5169,7 @@ const deserializeAws_json1_1ListBranchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -5157,10 +5200,12 @@ const deserializeAws_json1_1ListBranchesCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5192,8 +5237,7 @@ const deserializeAws_json1_1ListPullRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorDoesNotExistException": case "com.amazonaws.codecommit#AuthorDoesNotExistException": @@ -5236,10 +5280,12 @@ const deserializeAws_json1_1ListPullRequestsCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5271,8 +5317,7 @@ const deserializeAws_json1_1ListRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidContinuationTokenException": case "com.amazonaws.codecommit#InvalidContinuationTokenException": @@ -5285,10 +5330,12 @@ const deserializeAws_json1_1ListRepositoriesCommandError = async ( throw await deserializeAws_json1_1InvalidSortByExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5320,8 +5367,7 @@ const deserializeAws_json1_1ListRepositoriesForApprovalRuleTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -5355,10 +5401,12 @@ const deserializeAws_json1_1ListRepositoriesForApprovalRuleTemplateCommandError throw await deserializeAws_json1_1InvalidMaxResultsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5390,8 +5438,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRepositoryNameException": case "com.amazonaws.codecommit#InvalidRepositoryNameException": @@ -5407,10 +5454,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceArnRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5442,8 +5491,7 @@ const deserializeAws_json1_1MergeBranchesByFastForwardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -5504,10 +5552,12 @@ const deserializeAws_json1_1MergeBranchesByFastForwardCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5539,8 +5589,7 @@ const deserializeAws_json1_1MergeBranchesBySquashCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -5664,10 +5713,12 @@ const deserializeAws_json1_1MergeBranchesBySquashCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5699,8 +5750,7 @@ const deserializeAws_json1_1MergeBranchesByThreeWayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -5824,10 +5874,12 @@ const deserializeAws_json1_1MergeBranchesByThreeWayCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5859,8 +5911,7 @@ const deserializeAws_json1_1MergePullRequestByFastForwardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentReferenceUpdateException": case "com.amazonaws.codecommit#ConcurrentReferenceUpdateException": @@ -5921,10 +5972,12 @@ const deserializeAws_json1_1MergePullRequestByFastForwardCommandError = async ( throw await deserializeAws_json1_1TipOfSourceReferenceIsDifferentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5956,8 +6009,7 @@ const deserializeAws_json1_1MergePullRequestBySquashCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitMessageLengthExceededException": case "com.amazonaws.codecommit#CommitMessageLengthExceededException": @@ -6078,10 +6130,12 @@ const deserializeAws_json1_1MergePullRequestBySquashCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6113,8 +6167,7 @@ const deserializeAws_json1_1MergePullRequestByThreeWayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommitMessageLengthExceededException": case "com.amazonaws.codecommit#CommitMessageLengthExceededException": @@ -6235,10 +6288,12 @@ const deserializeAws_json1_1MergePullRequestByThreeWayCommandError = async ( throw await deserializeAws_json1_1TipsDivergenceExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6267,8 +6322,7 @@ const deserializeAws_json1_1OverridePullRequestApprovalRulesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -6317,10 +6371,12 @@ const deserializeAws_json1_1OverridePullRequestApprovalRulesCommandError = async throw await deserializeAws_json1_1RevisionNotCurrentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6352,8 +6408,7 @@ const deserializeAws_json1_1PostCommentForComparedCommitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BeforeCommitIdAndAfterCommitIdAreSameException": case "com.amazonaws.codecommit#BeforeCommitIdAndAfterCommitIdAreSameException": @@ -6426,10 +6481,12 @@ const deserializeAws_json1_1PostCommentForComparedCommitCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6461,8 +6518,7 @@ const deserializeAws_json1_1PostCommentForPullRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BeforeCommitIdAndAfterCommitIdAreSameException": case "com.amazonaws.codecommit#BeforeCommitIdAndAfterCommitIdAreSameException": @@ -6547,10 +6603,12 @@ const deserializeAws_json1_1PostCommentForPullRequestCommandError = async ( throw await deserializeAws_json1_1RepositoryNotAssociatedWithPullRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6582,8 +6640,7 @@ const deserializeAws_json1_1PostCommentReplyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientRequestTokenRequiredException": case "com.amazonaws.codecommit#ClientRequestTokenRequiredException": @@ -6611,10 +6668,12 @@ const deserializeAws_json1_1PostCommentReplyCommandError = async ( throw await deserializeAws_json1_1InvalidCommentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6643,8 +6702,7 @@ const deserializeAws_json1_1PutCommentReactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommentDeletedException": case "com.amazonaws.codecommit#CommentDeletedException": @@ -6669,10 +6727,12 @@ const deserializeAws_json1_1PutCommentReactionCommandError = async ( throw await deserializeAws_json1_1ReactionValueRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6704,8 +6764,7 @@ const deserializeAws_json1_1PutFileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -6799,10 +6858,12 @@ const deserializeAws_json1_1PutFileCommandError = async ( throw await deserializeAws_json1_1SameFileContentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6834,8 +6895,7 @@ const deserializeAws_json1_1PutRepositoryTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -6902,10 +6962,12 @@ const deserializeAws_json1_1PutRepositoryTriggersCommandError = async ( throw await deserializeAws_json1_1RepositoryTriggersListRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6934,8 +6996,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRepositoryNameException": case "com.amazonaws.codecommit#InvalidRepositoryNameException": @@ -6966,10 +7027,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7001,8 +7064,7 @@ const deserializeAws_json1_1TestRepositoryTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -7069,10 +7131,12 @@ const deserializeAws_json1_1TestRepositoryTriggersCommandError = async ( throw await deserializeAws_json1_1RepositoryTriggersListRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7101,8 +7165,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRepositoryNameException": case "com.amazonaws.codecommit#InvalidRepositoryNameException": @@ -7133,10 +7196,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7168,8 +7233,7 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateContentCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateContentRequiredException": case "com.amazonaws.codecommit#ApprovalRuleTemplateContentRequiredException": @@ -7191,10 +7255,12 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateContentCommandError = asyn throw await deserializeAws_json1_1InvalidRuleContentSha256ExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7226,8 +7292,7 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateDescriptionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -7243,10 +7308,12 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateDescriptionCommandError = throw await deserializeAws_json1_1InvalidApprovalRuleTemplateNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7278,8 +7345,7 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleTemplateDoesNotExistException": case "com.amazonaws.codecommit#ApprovalRuleTemplateDoesNotExistException": @@ -7295,10 +7361,12 @@ const deserializeAws_json1_1UpdateApprovalRuleTemplateNameCommandError = async ( throw await deserializeAws_json1_1InvalidApprovalRuleTemplateNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7330,8 +7398,7 @@ const deserializeAws_json1_1UpdateCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CommentContentRequiredException": case "com.amazonaws.codecommit#CommentContentRequiredException": @@ -7356,10 +7423,12 @@ const deserializeAws_json1_1UpdateCommentCommandError = async ( throw await deserializeAws_json1_1InvalidCommentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7388,8 +7457,7 @@ const deserializeAws_json1_1UpdateDefaultBranchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BranchDoesNotExistException": case "com.amazonaws.codecommit#BranchDoesNotExistException": @@ -7426,10 +7494,12 @@ const deserializeAws_json1_1UpdateDefaultBranchCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7461,8 +7531,7 @@ const deserializeAws_json1_1UpdatePullRequestApprovalRuleContentCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalRuleContentRequiredException": case "com.amazonaws.codecommit#ApprovalRuleContentRequiredException": @@ -7514,10 +7583,12 @@ const deserializeAws_json1_1UpdatePullRequestApprovalRuleContentCommandError = a throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7546,8 +7617,7 @@ const deserializeAws_json1_1UpdatePullRequestApprovalStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApprovalStateRequiredException": case "com.amazonaws.codecommit#ApprovalStateRequiredException": @@ -7599,10 +7669,12 @@ const deserializeAws_json1_1UpdatePullRequestApprovalStateCommandError = async ( throw await deserializeAws_json1_1RevisionNotCurrentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7634,8 +7706,7 @@ const deserializeAws_json1_1UpdatePullRequestDescriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDescriptionException": case "com.amazonaws.codecommit#InvalidDescriptionException": @@ -7654,10 +7725,12 @@ const deserializeAws_json1_1UpdatePullRequestDescriptionCommandError = async ( throw await deserializeAws_json1_1PullRequestIdRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7689,8 +7762,7 @@ const deserializeAws_json1_1UpdatePullRequestStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -7727,10 +7799,12 @@ const deserializeAws_json1_1UpdatePullRequestStatusCommandError = async ( throw await deserializeAws_json1_1PullRequestStatusRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7762,8 +7836,7 @@ const deserializeAws_json1_1UpdatePullRequestTitleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPullRequestIdException": case "com.amazonaws.codecommit#InvalidPullRequestIdException": @@ -7785,10 +7858,12 @@ const deserializeAws_json1_1UpdatePullRequestTitleCommandError = async ( throw await deserializeAws_json1_1TitleRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7817,8 +7892,7 @@ const deserializeAws_json1_1UpdateRepositoryDescriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EncryptionIntegrityChecksFailedException": case "com.amazonaws.codecommit#EncryptionIntegrityChecksFailedException": @@ -7849,10 +7923,12 @@ const deserializeAws_json1_1UpdateRepositoryDescriptionCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7881,8 +7957,7 @@ const deserializeAws_json1_1UpdateRepositoryNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRepositoryNameException": case "com.amazonaws.codecommit#InvalidRepositoryNameException": @@ -7898,10 +7973,12 @@ const deserializeAws_json1_1UpdateRepositoryNameCommandError = async ( throw await deserializeAws_json1_1RepositoryNameRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15193,7 +15270,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -15219,6 +15296,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codedeploy/src/protocols/Aws_json1_1.ts b/clients/client-codedeploy/src/protocols/Aws_json1_1.ts index f566e056b6fec..ebc2d0dcd8b58 100644 --- a/clients/client-codedeploy/src/protocols/Aws_json1_1.ts +++ b/clients/client-codedeploy/src/protocols/Aws_json1_1.ts @@ -1058,8 +1058,7 @@ const deserializeAws_json1_1AddTagsToOnPremisesInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceLimitExceededException": case "com.amazonaws.codedeploy#InstanceLimitExceededException": @@ -1084,10 +1083,12 @@ const deserializeAws_json1_1AddTagsToOnPremisesInstancesCommandError = async ( throw await deserializeAws_json1_1TagRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1119,8 +1120,7 @@ const deserializeAws_json1_1BatchGetApplicationRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -1142,10 +1142,12 @@ const deserializeAws_json1_1BatchGetApplicationRevisionsCommandError = async ( throw await deserializeAws_json1_1RevisionRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1177,8 +1179,7 @@ const deserializeAws_json1_1BatchGetApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -1194,10 +1195,12 @@ const deserializeAws_json1_1BatchGetApplicationsCommandError = async ( throw await deserializeAws_json1_1InvalidApplicationNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1229,8 +1232,7 @@ const deserializeAws_json1_1BatchGetDeploymentGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -1255,10 +1257,12 @@ const deserializeAws_json1_1BatchGetDeploymentGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentGroupNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1290,8 +1294,7 @@ const deserializeAws_json1_1BatchGetDeploymentInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchLimitExceededException": case "com.amazonaws.codedeploy#BatchLimitExceededException": @@ -1316,10 +1319,12 @@ const deserializeAws_json1_1BatchGetDeploymentInstancesCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1351,8 +1356,7 @@ const deserializeAws_json1_1BatchGetDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchLimitExceededException": case "com.amazonaws.codedeploy#BatchLimitExceededException": @@ -1365,10 +1369,12 @@ const deserializeAws_json1_1BatchGetDeploymentsCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1400,8 +1406,7 @@ const deserializeAws_json1_1BatchGetDeploymentTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -1432,10 +1437,12 @@ const deserializeAws_json1_1BatchGetDeploymentTargetsCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentTargetIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1467,8 +1474,7 @@ const deserializeAws_json1_1BatchGetOnPremisesInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchLimitExceededException": case "com.amazonaws.codedeploy#BatchLimitExceededException": @@ -1481,10 +1487,12 @@ const deserializeAws_json1_1BatchGetOnPremisesInstancesCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1513,8 +1521,7 @@ const deserializeAws_json1_1ContinueDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentAlreadyCompletedException": case "com.amazonaws.codedeploy#DeploymentAlreadyCompletedException": @@ -1542,10 +1549,12 @@ const deserializeAws_json1_1ContinueDeploymentCommandError = async ( throw await deserializeAws_json1_1UnsupportedActionForDeploymentTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1586,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationAlreadyExistsException": case "com.amazonaws.codedeploy#ApplicationAlreadyExistsException": @@ -1600,10 +1608,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1InvalidTagsToAddExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1635,8 +1645,7 @@ const deserializeAws_json1_1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -1715,10 +1724,12 @@ const deserializeAws_json1_1CreateDeploymentCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1750,8 +1761,7 @@ const deserializeAws_json1_1CreateDeploymentConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentConfigAlreadyExistsException": case "com.amazonaws.codedeploy#DeploymentConfigAlreadyExistsException": @@ -1776,10 +1786,12 @@ const deserializeAws_json1_1CreateDeploymentConfigCommandError = async ( throw await deserializeAws_json1_1InvalidTrafficRoutingConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1811,8 +1823,7 @@ const deserializeAws_json1_1CreateDeploymentGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlarmsLimitExceededException": case "com.amazonaws.codedeploy#AlarmsLimitExceededException": @@ -1915,10 +1926,12 @@ const deserializeAws_json1_1CreateDeploymentGroupCommandError = async ( throw await deserializeAws_json1_1TriggerTargetsLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1947,8 +1960,7 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationNameRequiredException": case "com.amazonaws.codedeploy#ApplicationNameRequiredException": @@ -1961,10 +1973,12 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( throw await deserializeAws_json1_1InvalidRoleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1993,8 +2007,7 @@ const deserializeAws_json1_1DeleteDeploymentConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentConfigInUseException": case "com.amazonaws.codedeploy#DeploymentConfigInUseException": @@ -2010,10 +2023,12 @@ const deserializeAws_json1_1DeleteDeploymentConfigCommandError = async ( throw await deserializeAws_json1_1InvalidOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2060,7 @@ const deserializeAws_json1_1DeleteDeploymentGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationNameRequiredException": case "com.amazonaws.codedeploy#ApplicationNameRequiredException": @@ -2065,10 +2079,12 @@ const deserializeAws_json1_1DeleteDeploymentGroupCommandError = async ( throw await deserializeAws_json1_1InvalidRoleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2100,8 +2116,7 @@ const deserializeAws_json1_1DeleteGitHubAccountTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GitHubAccountTokenDoesNotExistException": case "com.amazonaws.codedeploy#GitHubAccountTokenDoesNotExistException": @@ -2120,10 +2135,12 @@ const deserializeAws_json1_1DeleteGitHubAccountTokenCommandError = async ( throw await deserializeAws_json1_1ResourceValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2155,15 +2172,16 @@ const deserializeAws_json1_1DeleteResourcesByExternalIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2192,8 +2210,7 @@ const deserializeAws_json1_1DeregisterOnPremisesInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceNameRequiredException": case "com.amazonaws.codedeploy#InstanceNameRequiredException": @@ -2203,10 +2220,12 @@ const deserializeAws_json1_1DeregisterOnPremisesInstanceCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2238,8 +2257,7 @@ const deserializeAws_json1_1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2252,10 +2270,12 @@ const deserializeAws_json1_1GetApplicationCommandError = async ( throw await deserializeAws_json1_1InvalidApplicationNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2287,8 +2307,7 @@ const deserializeAws_json1_1GetApplicationRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2310,10 +2329,12 @@ const deserializeAws_json1_1GetApplicationRevisionCommandError = async ( throw await deserializeAws_json1_1RevisionRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2345,8 +2366,7 @@ const deserializeAws_json1_1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -2359,10 +2379,12 @@ const deserializeAws_json1_1GetDeploymentCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentIdExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2394,8 +2416,7 @@ const deserializeAws_json1_1GetDeploymentConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentConfigDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentConfigDoesNotExistException": @@ -2411,10 +2432,12 @@ const deserializeAws_json1_1GetDeploymentConfigCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentConfigNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2446,8 +2469,7 @@ const deserializeAws_json1_1GetDeploymentGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2472,10 +2494,12 @@ const deserializeAws_json1_1GetDeploymentGroupCommandError = async ( throw await deserializeAws_json1_1InvalidDeploymentGroupNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2507,8 +2531,7 @@ const deserializeAws_json1_1GetDeploymentInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -2533,10 +2556,12 @@ const deserializeAws_json1_1GetDeploymentInstanceCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2568,8 +2593,7 @@ const deserializeAws_json1_1GetDeploymentTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -2597,10 +2621,12 @@ const deserializeAws_json1_1GetDeploymentTargetCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2632,8 +2658,7 @@ const deserializeAws_json1_1GetOnPremisesInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceNameRequiredException": case "com.amazonaws.codedeploy#InstanceNameRequiredException": @@ -2646,10 +2671,12 @@ const deserializeAws_json1_1GetOnPremisesInstanceCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2681,8 +2708,7 @@ const deserializeAws_json1_1ListApplicationRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2716,10 +2742,12 @@ const deserializeAws_json1_1ListApplicationRevisionsCommandError = async ( throw await deserializeAws_json1_1InvalidSortOrderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2751,18 +2779,19 @@ const deserializeAws_json1_1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codedeploy#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2794,18 +2823,19 @@ const deserializeAws_json1_1ListDeploymentConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codedeploy#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2837,8 +2867,7 @@ const deserializeAws_json1_1ListDeploymentGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2854,10 +2883,12 @@ const deserializeAws_json1_1ListDeploymentGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2889,8 +2920,7 @@ const deserializeAws_json1_1ListDeploymentInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -2924,10 +2954,12 @@ const deserializeAws_json1_1ListDeploymentInstancesCommandError = async ( throw await deserializeAws_json1_1InvalidTargetFilterNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2959,8 +2991,7 @@ const deserializeAws_json1_1ListDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -2997,10 +3028,12 @@ const deserializeAws_json1_1ListDeploymentsCommandError = async ( throw await deserializeAws_json1_1InvalidTimeRangeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3032,8 +3065,7 @@ const deserializeAws_json1_1ListDeploymentTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -3061,10 +3093,12 @@ const deserializeAws_json1_1ListDeploymentTargetsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3096,8 +3130,7 @@ const deserializeAws_json1_1ListGitHubAccountTokenNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codedeploy#InvalidNextTokenException": @@ -3110,10 +3143,12 @@ const deserializeAws_json1_1ListGitHubAccountTokenNamesCommandError = async ( throw await deserializeAws_json1_1ResourceValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3145,8 +3180,7 @@ const deserializeAws_json1_1ListOnPremisesInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codedeploy#InvalidNextTokenException": @@ -3159,10 +3193,12 @@ const deserializeAws_json1_1ListOnPremisesInstancesCommandError = async ( throw await deserializeAws_json1_1InvalidTagFilterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3194,8 +3230,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArnNotSupportedException": case "com.amazonaws.codedeploy#ArnNotSupportedException": @@ -3208,10 +3243,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceArnRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3243,8 +3280,7 @@ const deserializeAws_json1_1PutLifecycleEventHookExecutionStatusCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentDoesNotExistException": case "com.amazonaws.codedeploy#DeploymentDoesNotExistException": @@ -3272,10 +3308,12 @@ const deserializeAws_json1_1PutLifecycleEventHookExecutionStatusCommandError = a throw await deserializeAws_json1_1UnsupportedActionForDeploymentTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3304,8 +3342,7 @@ const deserializeAws_json1_1RegisterApplicationRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -3327,10 +3364,12 @@ const deserializeAws_json1_1RegisterApplicationRevisionCommandError = async ( throw await deserializeAws_json1_1RevisionRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3359,8 +3398,7 @@ const deserializeAws_json1_1RegisterOnPremisesInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IamArnRequiredException": case "com.amazonaws.codedeploy#IamArnRequiredException": @@ -3394,10 +3432,12 @@ const deserializeAws_json1_1RegisterOnPremisesInstanceCommandError = async ( throw await deserializeAws_json1_1MultipleIamArnsProvidedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3426,8 +3466,7 @@ const deserializeAws_json1_1RemoveTagsFromOnPremisesInstancesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceLimitExceededException": case "com.amazonaws.codedeploy#InstanceLimitExceededException": @@ -3452,10 +3491,12 @@ const deserializeAws_json1_1RemoveTagsFromOnPremisesInstancesCommandError = asyn throw await deserializeAws_json1_1TagRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3484,8 +3525,7 @@ const deserializeAws_json1_1SkipWaitTimeForInstanceTerminationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentAlreadyCompletedException": case "com.amazonaws.codedeploy#DeploymentAlreadyCompletedException": @@ -3507,10 +3547,12 @@ const deserializeAws_json1_1SkipWaitTimeForInstanceTerminationCommandError = asy throw await deserializeAws_json1_1UnsupportedActionForDeploymentTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3542,8 +3584,7 @@ const deserializeAws_json1_1StopDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeploymentAlreadyCompletedException": case "com.amazonaws.codedeploy#DeploymentAlreadyCompletedException": @@ -3565,10 +3606,12 @@ const deserializeAws_json1_1StopDeploymentCommandError = async ( throw await deserializeAws_json1_1UnsupportedActionForDeploymentTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3600,8 +3643,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -3629,10 +3671,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TagRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3664,8 +3708,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationDoesNotExistException": case "com.amazonaws.codedeploy#ApplicationDoesNotExistException": @@ -3693,10 +3736,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TagRequiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3725,8 +3770,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ApplicationAlreadyExistsException": case "com.amazonaws.codedeploy#ApplicationAlreadyExistsException": @@ -3742,10 +3786,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1InvalidApplicationNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3777,8 +3823,7 @@ const deserializeAws_json1_1UpdateDeploymentGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlarmsLimitExceededException": case "com.amazonaws.codedeploy#AlarmsLimitExceededException": @@ -3875,10 +3920,12 @@ const deserializeAws_json1_1UpdateDeploymentGroupCommandError = async ( throw await deserializeAws_json1_1TriggerTargetsLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9200,7 +9247,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9226,6 +9273,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codeguru-reviewer/src/protocols/Aws_restJson1.ts b/clients/client-codeguru-reviewer/src/protocols/Aws_restJson1.ts index 049e6a0c68fa2..cc80e82a0ca18 100644 --- a/clients/client-codeguru-reviewer/src/protocols/Aws_restJson1.ts +++ b/clients/client-codeguru-reviewer/src/protocols/Aws_restJson1.ts @@ -567,8 +567,7 @@ const deserializeAws_restJson1AssociateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -587,10 +586,12 @@ const deserializeAws_restJson1AssociateRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -623,8 +624,7 @@ const deserializeAws_restJson1CreateCodeReviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -646,10 +646,12 @@ const deserializeAws_restJson1CreateCodeReviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -682,8 +684,7 @@ const deserializeAws_restJson1DescribeCodeReviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -702,10 +703,12 @@ const deserializeAws_restJson1DescribeCodeReviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -741,8 +744,7 @@ const deserializeAws_restJson1DescribeRecommendationFeedbackCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -761,10 +763,12 @@ const deserializeAws_restJson1DescribeRecommendationFeedbackCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -801,8 +805,7 @@ const deserializeAws_restJson1DescribeRepositoryAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -821,10 +824,12 @@ const deserializeAws_restJson1DescribeRepositoryAssociationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -861,8 +866,7 @@ const deserializeAws_restJson1DisassociateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -884,10 +888,12 @@ const deserializeAws_restJson1DisassociateRepositoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -924,8 +930,7 @@ const deserializeAws_restJson1ListCodeReviewsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -941,10 +946,12 @@ const deserializeAws_restJson1ListCodeReviewsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -984,8 +991,7 @@ const deserializeAws_restJson1ListRecommendationFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -1004,10 +1010,12 @@ const deserializeAws_restJson1ListRecommendationFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1047,8 +1055,7 @@ const deserializeAws_restJson1ListRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -1067,10 +1074,12 @@ const deserializeAws_restJson1ListRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1110,8 +1119,7 @@ const deserializeAws_restJson1ListRepositoryAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codegurureviewer#InternalServerException": @@ -1124,10 +1132,12 @@ const deserializeAws_restJson1ListRepositoryAssociationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1170,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codegurureviewer#InternalServerException": @@ -1174,10 +1183,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1217,7 @@ const deserializeAws_restJson1PutRecommendationFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codegurureviewer#AccessDeniedException": @@ -1226,10 +1236,12 @@ const deserializeAws_restJson1PutRecommendationFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1258,8 +1270,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codegurureviewer#InternalServerException": @@ -1272,10 +1283,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,8 +1317,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codegurureviewer#InternalServerException": @@ -1318,10 +1330,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2100,7 +2114,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2126,6 +2140,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codeguruprofiler/src/protocols/Aws_restJson1.ts b/clients/client-codeguruprofiler/src/protocols/Aws_restJson1.ts index 264eb3a607072..67371549f83de 100644 --- a/clients/client-codeguruprofiler/src/protocols/Aws_restJson1.ts +++ b/clients/client-codeguruprofiler/src/protocols/Aws_restJson1.ts @@ -964,8 +964,7 @@ const deserializeAws_restJson1AddNotificationChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -987,10 +986,12 @@ const deserializeAws_restJson1AddNotificationChannelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1043,8 +1044,7 @@ const deserializeAws_restJson1BatchGetFrameMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1060,10 +1060,12 @@ const deserializeAws_restJson1BatchGetFrameMetricDataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1094,8 +1096,7 @@ const deserializeAws_restJson1ConfigureAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1111,10 +1112,12 @@ const deserializeAws_restJson1ConfigureAgentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1145,8 +1148,7 @@ const deserializeAws_restJson1CreateProfilingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -1165,10 +1167,12 @@ const deserializeAws_restJson1CreateProfilingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1197,8 +1201,7 @@ const deserializeAws_restJson1DeleteProfilingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -1217,10 +1220,12 @@ const deserializeAws_restJson1DeleteProfilingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1251,8 +1256,7 @@ const deserializeAws_restJson1DescribeProfilingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1268,10 +1272,12 @@ const deserializeAws_restJson1DescribeProfilingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1308,8 +1314,7 @@ const deserializeAws_restJson1GetFindingsReportAccountSummaryCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1322,10 +1327,12 @@ const deserializeAws_restJson1GetFindingsReportAccountSummaryCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1361,8 +1368,7 @@ const deserializeAws_restJson1GetNotificationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1378,10 +1384,12 @@ const deserializeAws_restJson1GetNotificationConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1418,8 +1426,7 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1432,10 +1439,12 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1474,8 +1483,7 @@ const deserializeAws_restJson1GetProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1491,10 +1499,12 @@ const deserializeAws_restJson1GetProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1543,8 +1553,7 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1560,10 +1569,12 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1614,7 @@ const deserializeAws_restJson1ListFindingsReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1620,10 +1630,12 @@ const deserializeAws_restJson1ListFindingsReportsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1660,8 +1672,7 @@ const deserializeAws_restJson1ListProfileTimesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1677,10 +1688,12 @@ const deserializeAws_restJson1ListProfileTimesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1721,8 +1734,7 @@ const deserializeAws_restJson1ListProfilingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1732,10 +1744,12 @@ const deserializeAws_restJson1ListProfilingGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1782,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1782,10 +1795,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1829,7 @@ const deserializeAws_restJson1PostAgentProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1831,10 +1845,12 @@ const deserializeAws_restJson1PostAgentProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1871,8 +1887,7 @@ const deserializeAws_restJson1PutPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -1891,10 +1906,12 @@ const deserializeAws_restJson1PutPermissionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1930,8 +1947,7 @@ const deserializeAws_restJson1RemoveNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -1947,10 +1963,12 @@ const deserializeAws_restJson1RemoveNotificationChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1987,8 +2005,7 @@ const deserializeAws_restJson1RemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -2007,10 +2024,12 @@ const deserializeAws_restJson1RemovePermissionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2039,8 +2058,7 @@ const deserializeAws_restJson1SubmitFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -2056,10 +2074,12 @@ const deserializeAws_restJson1SubmitFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2088,8 +2108,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -2102,10 +2121,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2134,8 +2155,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.codeguruprofiler#InternalServerException": @@ -2148,10 +2168,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2204,7 @@ const deserializeAws_restJson1UpdateProfilingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codeguruprofiler#ConflictException": @@ -2202,10 +2223,12 @@ const deserializeAws_restJson1UpdateProfilingGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2962,7 +2985,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2988,6 +3011,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codepipeline/src/protocols/Aws_json1_1.ts b/clients/client-codepipeline/src/protocols/Aws_json1_1.ts index f3e62d49bc5ef..d0469d6ac0005 100644 --- a/clients/client-codepipeline/src/protocols/Aws_json1_1.ts +++ b/clients/client-codepipeline/src/protocols/Aws_json1_1.ts @@ -826,8 +826,7 @@ const deserializeAws_json1_1AcknowledgeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNonceException": case "com.amazonaws.codepipeline#InvalidNonceException": @@ -840,10 +839,12 @@ const deserializeAws_json1_1AcknowledgeJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -875,8 +876,7 @@ const deserializeAws_json1_1AcknowledgeThirdPartyJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.codepipeline#InvalidClientTokenException": @@ -892,10 +892,12 @@ const deserializeAws_json1_1AcknowledgeThirdPartyJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -927,8 +929,7 @@ const deserializeAws_json1_1CreateCustomActionTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -947,10 +948,12 @@ const deserializeAws_json1_1CreateCustomActionTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -982,8 +985,7 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -1017,10 +1019,12 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1049,8 +1053,7 @@ const deserializeAws_json1_1DeleteCustomActionTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -1060,10 +1063,12 @@ const deserializeAws_json1_1DeleteCustomActionTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1092,8 +1097,7 @@ const deserializeAws_json1_1DeletePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -1103,10 +1107,12 @@ const deserializeAws_json1_1DeletePipelineCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1138,8 +1144,7 @@ const deserializeAws_json1_1DeleteWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -1149,10 +1154,12 @@ const deserializeAws_json1_1DeleteWebhookCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1184,8 +1191,7 @@ const deserializeAws_json1_1DeregisterWebhookWithThirdPartyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.codepipeline#ValidationException": @@ -1195,10 +1201,12 @@ const deserializeAws_json1_1DeregisterWebhookWithThirdPartyCommandError = async throw await deserializeAws_json1_1WebhookNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1227,8 +1235,7 @@ const deserializeAws_json1_1DisableStageTransitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PipelineNotFoundException": case "com.amazonaws.codepipeline#PipelineNotFoundException": @@ -1241,10 +1248,12 @@ const deserializeAws_json1_1DisableStageTransitionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1273,8 +1282,7 @@ const deserializeAws_json1_1EnableStageTransitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PipelineNotFoundException": case "com.amazonaws.codepipeline#PipelineNotFoundException": @@ -1287,10 +1295,12 @@ const deserializeAws_json1_1EnableStageTransitionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1332,7 @@ const deserializeAws_json1_1GetActionTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionTypeNotFoundException": case "com.amazonaws.codepipeline#ActionTypeNotFoundException": @@ -1333,10 +1342,12 @@ const deserializeAws_json1_1GetActionTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1368,8 +1379,7 @@ const deserializeAws_json1_1GetJobDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "JobNotFoundException": case "com.amazonaws.codepipeline#JobNotFoundException": @@ -1379,10 +1389,12 @@ const deserializeAws_json1_1GetJobDetailsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1414,8 +1426,7 @@ const deserializeAws_json1_1GetPipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PipelineNotFoundException": case "com.amazonaws.codepipeline#PipelineNotFoundException": @@ -1428,10 +1439,12 @@ const deserializeAws_json1_1GetPipelineCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1463,8 +1476,7 @@ const deserializeAws_json1_1GetPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PipelineExecutionNotFoundException": case "com.amazonaws.codepipeline#PipelineExecutionNotFoundException": @@ -1477,10 +1489,12 @@ const deserializeAws_json1_1GetPipelineExecutionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1512,8 +1526,7 @@ const deserializeAws_json1_1GetPipelineStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PipelineNotFoundException": case "com.amazonaws.codepipeline#PipelineNotFoundException": @@ -1523,10 +1536,12 @@ const deserializeAws_json1_1GetPipelineStateCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1558,8 +1573,7 @@ const deserializeAws_json1_1GetThirdPartyJobDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.codepipeline#InvalidClientTokenException": @@ -1575,10 +1589,12 @@ const deserializeAws_json1_1GetThirdPartyJobDetailsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1610,8 +1626,7 @@ const deserializeAws_json1_1ListActionExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codepipeline#InvalidNextTokenException": @@ -1627,10 +1642,12 @@ const deserializeAws_json1_1ListActionExecutionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1662,8 +1679,7 @@ const deserializeAws_json1_1ListActionTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codepipeline#InvalidNextTokenException": @@ -1673,10 +1689,12 @@ const deserializeAws_json1_1ListActionTypesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1708,8 +1726,7 @@ const deserializeAws_json1_1ListPipelineExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codepipeline#InvalidNextTokenException": @@ -1722,10 +1739,12 @@ const deserializeAws_json1_1ListPipelineExecutionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1757,8 +1776,7 @@ const deserializeAws_json1_1ListPipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codepipeline#InvalidNextTokenException": @@ -1768,10 +1786,12 @@ const deserializeAws_json1_1ListPipelinesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1803,8 +1823,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.codepipeline#InvalidArnException": @@ -1820,10 +1839,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1855,8 +1876,7 @@ const deserializeAws_json1_1ListWebhooksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codepipeline#InvalidNextTokenException": @@ -1866,10 +1886,12 @@ const deserializeAws_json1_1ListWebhooksCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1901,8 +1923,7 @@ const deserializeAws_json1_1PollForJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionTypeNotFoundException": case "com.amazonaws.codepipeline#ActionTypeNotFoundException": @@ -1912,10 +1933,12 @@ const deserializeAws_json1_1PollForJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1947,8 +1970,7 @@ const deserializeAws_json1_1PollForThirdPartyJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionTypeNotFoundException": case "com.amazonaws.codepipeline#ActionTypeNotFoundException": @@ -1958,10 +1980,12 @@ const deserializeAws_json1_1PollForThirdPartyJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1993,8 +2017,7 @@ const deserializeAws_json1_1PutActionRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionNotFoundException": case "com.amazonaws.codepipeline#ActionNotFoundException": @@ -2010,10 +2033,12 @@ const deserializeAws_json1_1PutActionRevisionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2070,7 @@ const deserializeAws_json1_1PutApprovalResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionNotFoundException": case "com.amazonaws.codepipeline#ActionNotFoundException": @@ -2068,10 +2092,12 @@ const deserializeAws_json1_1PutApprovalResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2100,8 +2126,7 @@ const deserializeAws_json1_1PutJobFailureResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.codepipeline#InvalidJobStateException": @@ -2114,10 +2139,12 @@ const deserializeAws_json1_1PutJobFailureResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2146,8 +2173,7 @@ const deserializeAws_json1_1PutJobSuccessResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.codepipeline#InvalidJobStateException": @@ -2163,10 +2189,12 @@ const deserializeAws_json1_1PutJobSuccessResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2195,8 +2223,7 @@ const deserializeAws_json1_1PutThirdPartyJobFailureResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.codepipeline#InvalidClientTokenException": @@ -2212,10 +2239,12 @@ const deserializeAws_json1_1PutThirdPartyJobFailureResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2244,8 +2273,7 @@ const deserializeAws_json1_1PutThirdPartyJobSuccessResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.codepipeline#InvalidClientTokenException": @@ -2261,10 +2289,12 @@ const deserializeAws_json1_1PutThirdPartyJobSuccessResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2296,8 +2326,7 @@ const deserializeAws_json1_1PutWebhookCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -2325,10 +2354,12 @@ const deserializeAws_json1_1PutWebhookCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2360,8 +2391,7 @@ const deserializeAws_json1_1RegisterWebhookWithThirdPartyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.codepipeline#ValidationException": @@ -2371,10 +2401,12 @@ const deserializeAws_json1_1RegisterWebhookWithThirdPartyCommandError = async ( throw await deserializeAws_json1_1WebhookNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2406,8 +2438,7 @@ const deserializeAws_json1_1RetryStageExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codepipeline#ConflictException": @@ -2429,10 +2460,12 @@ const deserializeAws_json1_1RetryStageExecutionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2464,8 +2497,7 @@ const deserializeAws_json1_1StartPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codepipeline#ConflictException": @@ -2478,10 +2510,12 @@ const deserializeAws_json1_1StartPipelineExecutionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2513,8 +2547,7 @@ const deserializeAws_json1_1StopPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codepipeline#ConflictException": @@ -2533,10 +2566,12 @@ const deserializeAws_json1_1StopPipelineExecutionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2568,8 +2603,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -2591,10 +2625,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2626,8 +2662,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codepipeline#ConcurrentModificationException": @@ -2646,10 +2681,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2678,8 +2715,7 @@ const deserializeAws_json1_1UpdateActionTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActionTypeNotFoundException": case "com.amazonaws.codepipeline#ActionTypeNotFoundException": @@ -2692,10 +2728,12 @@ const deserializeAws_json1_1UpdateActionTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2727,8 +2765,7 @@ const deserializeAws_json1_1UpdatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidActionDeclarationException": case "com.amazonaws.codepipeline#InvalidActionDeclarationException": @@ -2750,10 +2787,12 @@ const deserializeAws_json1_1UpdatePipelineCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6066,7 +6105,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6092,6 +6131,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codestar-connections/src/protocols/Aws_json1_0.ts b/clients/client-codestar-connections/src/protocols/Aws_json1_0.ts index 955039235f57a..0d2d302dc63c0 100644 --- a/clients/client-codestar-connections/src/protocols/Aws_json1_0.ts +++ b/clients/client-codestar-connections/src/protocols/Aws_json1_0.ts @@ -245,8 +245,7 @@ const deserializeAws_json1_0CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.codestarconnections#LimitExceededException": @@ -259,10 +258,12 @@ const deserializeAws_json1_0CreateConnectionCommandError = async ( throw await deserializeAws_json1_0ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -294,18 +295,19 @@ const deserializeAws_json1_0CreateHostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.codestarconnections#LimitExceededException": throw await deserializeAws_json1_0LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -337,18 +339,19 @@ const deserializeAws_json1_0DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -380,8 +383,7 @@ const deserializeAws_json1_0DeleteHostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": @@ -391,10 +393,12 @@ const deserializeAws_json1_0DeleteHostCommandError = async ( throw await deserializeAws_json1_0ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -426,8 +430,7 @@ const deserializeAws_json1_0GetConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": @@ -437,10 +440,12 @@ const deserializeAws_json1_0GetConnectionCommandError = async ( throw await deserializeAws_json1_0ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -472,8 +477,7 @@ const deserializeAws_json1_0GetHostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": @@ -483,10 +487,12 @@ const deserializeAws_json1_0GetHostCommandError = async ( throw await deserializeAws_json1_0ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -518,15 +524,16 @@ const deserializeAws_json1_0ListConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -558,15 +565,16 @@ const deserializeAws_json1_0ListHostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -598,18 +606,19 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -641,8 +650,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.codestarconnections#LimitExceededException": @@ -652,10 +660,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -687,18 +697,19 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarconnections#ResourceNotFoundException": throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -730,8 +741,7 @@ const deserializeAws_json1_0UpdateHostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.codestarconnections#ConflictException": @@ -747,10 +757,12 @@ const deserializeAws_json1_0UpdateHostCommandError = async ( throw await deserializeAws_json1_0UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1283,7 +1295,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1309,6 +1321,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codestar-notifications/src/protocols/Aws_restJson1.ts b/clients/client-codestar-notifications/src/protocols/Aws_restJson1.ts index 0acba6f488142..f8ccf0dce1126 100644 --- a/clients/client-codestar-notifications/src/protocols/Aws_restJson1.ts +++ b/clients/client-codestar-notifications/src/protocols/Aws_restJson1.ts @@ -445,8 +445,7 @@ const deserializeAws_restJson1CreateNotificationRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.codestarnotifications#AccessDeniedException": @@ -468,10 +467,12 @@ const deserializeAws_restJson1CreateNotificationRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -504,8 +505,7 @@ const deserializeAws_restJson1DeleteNotificationRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestarnotifications#ConcurrentModificationException": @@ -518,10 +518,12 @@ const deserializeAws_restJson1DeleteNotificationRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -550,18 +552,19 @@ const deserializeAws_restJson1DeleteTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.codestarnotifications#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -634,8 +637,7 @@ const deserializeAws_restJson1DescribeNotificationRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarnotifications#ResourceNotFoundException": @@ -645,10 +647,12 @@ const deserializeAws_restJson1DescribeNotificationRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -685,8 +689,7 @@ const deserializeAws_restJson1ListEventTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestarnotifications#InvalidNextTokenException": @@ -696,10 +699,12 @@ const deserializeAws_restJson1ListEventTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -736,8 +741,7 @@ const deserializeAws_restJson1ListNotificationRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestarnotifications#InvalidNextTokenException": @@ -747,10 +751,12 @@ const deserializeAws_restJson1ListNotificationRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -783,8 +789,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarnotifications#ResourceNotFoundException": @@ -794,10 +799,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -834,8 +841,7 @@ const deserializeAws_restJson1ListTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestarnotifications#InvalidNextTokenException": @@ -845,10 +851,12 @@ const deserializeAws_restJson1ListTargetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -881,8 +889,7 @@ const deserializeAws_restJson1SubscribeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarnotifications#ResourceNotFoundException": @@ -892,10 +899,12 @@ const deserializeAws_restJson1SubscribeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -928,8 +937,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestarnotifications#ConcurrentModificationException": @@ -942,10 +950,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -978,18 +988,19 @@ const deserializeAws_restJson1UnsubscribeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.codestarnotifications#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1018,8 +1029,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestarnotifications#ConcurrentModificationException": @@ -1032,10 +1042,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1064,8 +1076,7 @@ const deserializeAws_restJson1UpdateNotificationRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.codestarnotifications#ResourceNotFoundException": @@ -1075,10 +1086,12 @@ const deserializeAws_restJson1UpdateNotificationRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1439,7 +1452,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1465,6 +1478,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-codestar/src/protocols/Aws_json1_1.ts b/clients/client-codestar/src/protocols/Aws_json1_1.ts index f68864fe9db00..cef75562416da 100644 --- a/clients/client-codestar/src/protocols/Aws_json1_1.ts +++ b/clients/client-codestar/src/protocols/Aws_json1_1.ts @@ -368,8 +368,7 @@ const deserializeAws_json1_1AssociateTeamMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -394,10 +393,12 @@ const deserializeAws_json1_1AssociateTeamMemberCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -429,8 +430,7 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -455,10 +455,12 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -490,8 +492,7 @@ const deserializeAws_json1_1CreateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UserProfileAlreadyExistsException": case "com.amazonaws.codestar#UserProfileAlreadyExistsException": @@ -501,10 +502,12 @@ const deserializeAws_json1_1CreateUserProfileCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -536,8 +539,7 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -550,10 +552,12 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -585,18 +589,19 @@ const deserializeAws_json1_1DeleteUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.codestar#ValidationException": throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -628,8 +633,7 @@ const deserializeAws_json1_1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -648,10 +652,12 @@ const deserializeAws_json1_1DescribeProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -683,8 +689,7 @@ const deserializeAws_json1_1DescribeUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UserProfileNotFoundException": case "com.amazonaws.codestar#UserProfileNotFoundException": @@ -694,10 +699,12 @@ const deserializeAws_json1_1DescribeUserProfileCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -729,8 +736,7 @@ const deserializeAws_json1_1DisassociateTeamMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -746,10 +752,12 @@ const deserializeAws_json1_1DisassociateTeamMemberCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -781,8 +789,7 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestar#InvalidNextTokenException": @@ -792,10 +799,12 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -827,8 +836,7 @@ const deserializeAws_json1_1ListResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestar#InvalidNextTokenException": @@ -841,10 +849,12 @@ const deserializeAws_json1_1ListResourcesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -876,8 +886,7 @@ const deserializeAws_json1_1ListTagsForProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestar#InvalidNextTokenException": @@ -890,10 +899,12 @@ const deserializeAws_json1_1ListTagsForProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -925,8 +936,7 @@ const deserializeAws_json1_1ListTeamMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestar#InvalidNextTokenException": @@ -939,10 +949,12 @@ const deserializeAws_json1_1ListTeamMembersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -974,8 +986,7 @@ const deserializeAws_json1_1ListUserProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.codestar#InvalidNextTokenException": @@ -985,10 +996,12 @@ const deserializeAws_json1_1ListUserProfilesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1020,8 +1033,7 @@ const deserializeAws_json1_1TagProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -1037,10 +1049,12 @@ const deserializeAws_json1_1TagProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1072,8 +1086,7 @@ const deserializeAws_json1_1UntagProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -1089,10 +1102,12 @@ const deserializeAws_json1_1UntagProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1124,8 +1139,7 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ProjectNotFoundException": case "com.amazonaws.codestar#ProjectNotFoundException": @@ -1135,10 +1149,12 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1170,8 +1186,7 @@ const deserializeAws_json1_1UpdateTeamMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.codestar#ConcurrentModificationException": @@ -1196,10 +1211,12 @@ const deserializeAws_json1_1UpdateTeamMemberCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1231,8 +1248,7 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UserProfileNotFoundException": case "com.amazonaws.codestar#UserProfileNotFoundException": @@ -1242,10 +1258,12 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2167,7 +2185,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2193,6 +2211,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cognito-identity-provider/src/protocols/Aws_json1_1.ts b/clients/client-cognito-identity-provider/src/protocols/Aws_json1_1.ts index 52ead2f8950c3..5234f7b0d6be2 100644 --- a/clients/client-cognito-identity-provider/src/protocols/Aws_json1_1.ts +++ b/clients/client-cognito-identity-provider/src/protocols/Aws_json1_1.ts @@ -1934,8 +1934,7 @@ const deserializeAws_json1_1AddCustomAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -1957,10 +1956,12 @@ const deserializeAws_json1_1AddCustomAttributesCommandError = async ( throw await deserializeAws_json1_1UserImportInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1989,8 +1990,7 @@ const deserializeAws_json1_1AdminAddUserToGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2012,10 +2012,12 @@ const deserializeAws_json1_1AdminAddUserToGroupCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2047,8 +2049,7 @@ const deserializeAws_json1_1AdminConfirmSignUpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2085,10 +2086,12 @@ const deserializeAws_json1_1AdminConfirmSignUpCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2120,8 +2123,7 @@ const deserializeAws_json1_1AdminCreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -2173,10 +2175,12 @@ const deserializeAws_json1_1AdminCreateUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2205,8 +2209,7 @@ const deserializeAws_json1_1AdminDeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2228,10 +2231,12 @@ const deserializeAws_json1_1AdminDeleteUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2263,8 +2268,7 @@ const deserializeAws_json1_1AdminDeleteUserAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2286,10 +2290,12 @@ const deserializeAws_json1_1AdminDeleteUserAttributesCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2321,8 +2327,7 @@ const deserializeAws_json1_1AdminDisableProviderForUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -2347,10 +2352,12 @@ const deserializeAws_json1_1AdminDisableProviderForUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2382,8 +2389,7 @@ const deserializeAws_json1_1AdminDisableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2405,10 +2411,12 @@ const deserializeAws_json1_1AdminDisableUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2440,8 +2448,7 @@ const deserializeAws_json1_1AdminEnableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2463,10 +2470,12 @@ const deserializeAws_json1_1AdminEnableUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2495,8 +2504,7 @@ const deserializeAws_json1_1AdminForgetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2521,10 +2529,12 @@ const deserializeAws_json1_1AdminForgetDeviceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2556,8 +2566,7 @@ const deserializeAws_json1_1AdminGetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2579,10 +2588,12 @@ const deserializeAws_json1_1AdminGetDeviceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2614,8 +2625,7 @@ const deserializeAws_json1_1AdminGetUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2637,10 +2647,12 @@ const deserializeAws_json1_1AdminGetUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2672,8 +2684,7 @@ const deserializeAws_json1_1AdminInitiateAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2722,10 +2733,12 @@ const deserializeAws_json1_1AdminInitiateAuthCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2757,8 +2770,7 @@ const deserializeAws_json1_1AdminLinkProviderForUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -2786,10 +2798,12 @@ const deserializeAws_json1_1AdminLinkProviderForUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2821,8 +2835,7 @@ const deserializeAws_json1_1AdminListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2844,10 +2857,12 @@ const deserializeAws_json1_1AdminListDevicesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2879,8 +2894,7 @@ const deserializeAws_json1_1AdminListGroupsForUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2902,10 +2916,12 @@ const deserializeAws_json1_1AdminListGroupsForUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2937,8 +2953,7 @@ const deserializeAws_json1_1AdminListUserAuthEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -2963,10 +2978,12 @@ const deserializeAws_json1_1AdminListUserAuthEventsCommandError = async ( throw await deserializeAws_json1_1UserPoolAddOnNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2995,8 +3012,7 @@ const deserializeAws_json1_1AdminRemoveUserFromGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3018,10 +3034,12 @@ const deserializeAws_json1_1AdminRemoveUserFromGroupCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3053,8 +3071,7 @@ const deserializeAws_json1_1AdminResetUserPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3097,10 +3114,12 @@ const deserializeAws_json1_1AdminResetUserPasswordCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3132,8 +3151,7 @@ const deserializeAws_json1_1AdminRespondToAuthChallengeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -3197,10 +3215,12 @@ const deserializeAws_json1_1AdminRespondToAuthChallengeCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3232,8 +3252,7 @@ const deserializeAws_json1_1AdminSetUserMFAPreferenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3258,10 +3277,12 @@ const deserializeAws_json1_1AdminSetUserMFAPreferenceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3293,8 +3314,7 @@ const deserializeAws_json1_1AdminSetUserPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3319,10 +3339,12 @@ const deserializeAws_json1_1AdminSetUserPasswordCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3354,8 +3376,7 @@ const deserializeAws_json1_1AdminSetUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3374,10 +3395,12 @@ const deserializeAws_json1_1AdminSetUserSettingsCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3409,8 +3432,7 @@ const deserializeAws_json1_1AdminUpdateAuthEventFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3435,10 +3457,12 @@ const deserializeAws_json1_1AdminUpdateAuthEventFeedbackCommandError = async ( throw await deserializeAws_json1_1UserPoolAddOnNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3470,8 +3494,7 @@ const deserializeAws_json1_1AdminUpdateDeviceStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3496,10 +3519,12 @@ const deserializeAws_json1_1AdminUpdateDeviceStatusCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3531,8 +3556,7 @@ const deserializeAws_json1_1AdminUpdateUserAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -3575,10 +3599,12 @@ const deserializeAws_json1_1AdminUpdateUserAttributesCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3610,8 +3636,7 @@ const deserializeAws_json1_1AdminUserGlobalSignOutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3633,10 +3658,12 @@ const deserializeAws_json1_1AdminUserGlobalSignOutCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3668,8 +3695,7 @@ const deserializeAws_json1_1AssociateSoftwareTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitoidentityprovider#ConcurrentModificationException": @@ -3691,10 +3717,12 @@ const deserializeAws_json1_1AssociateSoftwareTokenCommandError = async ( throw await deserializeAws_json1_1SoftwareTokenMFANotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3726,8 +3754,7 @@ const deserializeAws_json1_1ChangePasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3761,10 +3788,12 @@ const deserializeAws_json1_1ChangePasswordCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3796,8 +3825,7 @@ const deserializeAws_json1_1ConfirmDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -3837,10 +3865,12 @@ const deserializeAws_json1_1ConfirmDeviceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3872,8 +3902,7 @@ const deserializeAws_json1_1ConfirmForgotPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeMismatchException": case "com.amazonaws.cognitoidentityprovider#CodeMismatchException": @@ -3922,10 +3951,12 @@ const deserializeAws_json1_1ConfirmForgotPasswordCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3957,8 +3988,7 @@ const deserializeAws_json1_1ConfirmSignUpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -4004,10 +4034,12 @@ const deserializeAws_json1_1ConfirmSignUpCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4039,8 +4071,7 @@ const deserializeAws_json1_1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GroupExistsException": case "com.amazonaws.cognitoidentityprovider#GroupExistsException": @@ -4065,10 +4096,12 @@ const deserializeAws_json1_1CreateGroupCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4100,8 +4133,7 @@ const deserializeAws_json1_1CreateIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateProviderException": case "com.amazonaws.cognitoidentityprovider#DuplicateProviderException": @@ -4126,10 +4158,12 @@ const deserializeAws_json1_1CreateIdentityProviderCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4161,8 +4195,7 @@ const deserializeAws_json1_1CreateResourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4184,10 +4217,12 @@ const deserializeAws_json1_1CreateResourceServerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4219,8 +4254,7 @@ const deserializeAws_json1_1CreateUserImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4245,10 +4279,12 @@ const deserializeAws_json1_1CreateUserImportJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4280,8 +4316,7 @@ const deserializeAws_json1_1CreateUserPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4312,10 +4347,12 @@ const deserializeAws_json1_1CreateUserPoolCommandError = async ( throw await deserializeAws_json1_1UserPoolTaggingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4347,8 +4384,7 @@ const deserializeAws_json1_1CreateUserPoolClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4376,10 +4412,12 @@ const deserializeAws_json1_1CreateUserPoolClientCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4411,8 +4449,7 @@ const deserializeAws_json1_1CreateUserPoolDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4431,10 +4468,12 @@ const deserializeAws_json1_1CreateUserPoolDomainCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4463,8 +4502,7 @@ const deserializeAws_json1_1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4483,10 +4521,12 @@ const deserializeAws_json1_1DeleteGroupCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4515,8 +4555,7 @@ const deserializeAws_json1_1DeleteIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4538,10 +4577,12 @@ const deserializeAws_json1_1DeleteIdentityProviderCommandError = async ( throw await deserializeAws_json1_1UnsupportedIdentityProviderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4570,8 +4611,7 @@ const deserializeAws_json1_1DeleteResourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4590,10 +4630,12 @@ const deserializeAws_json1_1DeleteResourceServerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4622,8 +4664,7 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4651,10 +4692,12 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4686,8 +4729,7 @@ const deserializeAws_json1_1DeleteUserAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4715,10 +4757,12 @@ const deserializeAws_json1_1DeleteUserAttributesCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4747,8 +4791,7 @@ const deserializeAws_json1_1DeleteUserPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4770,10 +4813,12 @@ const deserializeAws_json1_1DeleteUserPoolCommandError = async ( throw await deserializeAws_json1_1UserImportInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4802,8 +4847,7 @@ const deserializeAws_json1_1DeleteUserPoolClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4822,10 +4866,12 @@ const deserializeAws_json1_1DeleteUserPoolClientCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4857,8 +4903,7 @@ const deserializeAws_json1_1DeleteUserPoolDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4874,10 +4919,12 @@ const deserializeAws_json1_1DeleteUserPoolDomainCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4909,8 +4956,7 @@ const deserializeAws_json1_1DescribeIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4929,10 +4975,12 @@ const deserializeAws_json1_1DescribeIdentityProviderCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4964,8 +5012,7 @@ const deserializeAws_json1_1DescribeResourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -4984,10 +5031,12 @@ const deserializeAws_json1_1DescribeResourceServerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5019,8 +5068,7 @@ const deserializeAws_json1_1DescribeRiskConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5042,10 +5090,12 @@ const deserializeAws_json1_1DescribeRiskConfigurationCommandError = async ( throw await deserializeAws_json1_1UserPoolAddOnNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5077,8 +5127,7 @@ const deserializeAws_json1_1DescribeUserImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5097,10 +5146,12 @@ const deserializeAws_json1_1DescribeUserImportJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5132,8 +5183,7 @@ const deserializeAws_json1_1DescribeUserPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5155,10 +5205,12 @@ const deserializeAws_json1_1DescribeUserPoolCommandError = async ( throw await deserializeAws_json1_1UserPoolTaggingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5190,8 +5242,7 @@ const deserializeAws_json1_1DescribeUserPoolClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5210,10 +5261,12 @@ const deserializeAws_json1_1DescribeUserPoolClientCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5245,8 +5298,7 @@ const deserializeAws_json1_1DescribeUserPoolDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5262,10 +5314,12 @@ const deserializeAws_json1_1DescribeUserPoolDomainCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5294,8 +5348,7 @@ const deserializeAws_json1_1ForgetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5326,10 +5379,12 @@ const deserializeAws_json1_1ForgetDeviceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5361,8 +5416,7 @@ const deserializeAws_json1_1ForgotPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -5408,10 +5462,12 @@ const deserializeAws_json1_1ForgotPasswordCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5443,8 +5499,7 @@ const deserializeAws_json1_1GetCSVHeaderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5463,10 +5518,12 @@ const deserializeAws_json1_1GetCSVHeaderCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5498,8 +5555,7 @@ const deserializeAws_json1_1GetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5530,10 +5586,12 @@ const deserializeAws_json1_1GetDeviceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5565,8 +5623,7 @@ const deserializeAws_json1_1GetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5585,10 +5642,12 @@ const deserializeAws_json1_1GetGroupCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5620,8 +5679,7 @@ const deserializeAws_json1_1GetIdentityProviderByIdentifierCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5640,10 +5698,12 @@ const deserializeAws_json1_1GetIdentityProviderByIdentifierCommandError = async throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5675,8 +5735,7 @@ const deserializeAws_json1_1GetSigningCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5689,10 +5748,12 @@ const deserializeAws_json1_1GetSigningCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5724,8 +5785,7 @@ const deserializeAws_json1_1GetUICustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5744,10 +5804,12 @@ const deserializeAws_json1_1GetUICustomizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5779,8 +5841,7 @@ const deserializeAws_json1_1GetUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5808,10 +5869,12 @@ const deserializeAws_json1_1GetUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5843,8 +5906,7 @@ const deserializeAws_json1_1GetUserAttributeVerificationCodeCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -5896,10 +5958,12 @@ const deserializeAws_json1_1GetUserAttributeVerificationCodeCommandError = async throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5931,8 +5995,7 @@ const deserializeAws_json1_1GetUserPoolMfaConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -5951,10 +6014,12 @@ const deserializeAws_json1_1GetUserPoolMfaConfigCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5986,8 +6051,7 @@ const deserializeAws_json1_1GlobalSignOutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6012,10 +6076,12 @@ const deserializeAws_json1_1GlobalSignOutCommandError = async ( throw await deserializeAws_json1_1UserNotConfirmedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6047,8 +6113,7 @@ const deserializeAws_json1_1InitiateAuthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6094,10 +6159,12 @@ const deserializeAws_json1_1InitiateAuthCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6129,8 +6196,7 @@ const deserializeAws_json1_1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6161,10 +6227,12 @@ const deserializeAws_json1_1ListDevicesCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6196,8 +6264,7 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6216,10 +6283,12 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6251,8 +6320,7 @@ const deserializeAws_json1_1ListIdentityProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6271,10 +6339,12 @@ const deserializeAws_json1_1ListIdentityProvidersCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6306,8 +6376,7 @@ const deserializeAws_json1_1ListResourceServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6326,10 +6395,12 @@ const deserializeAws_json1_1ListResourceServersCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6361,8 +6432,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6381,10 +6451,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6416,8 +6488,7 @@ const deserializeAws_json1_1ListUserImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6436,10 +6507,12 @@ const deserializeAws_json1_1ListUserImportJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6471,8 +6544,7 @@ const deserializeAws_json1_1ListUserPoolClientsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6491,10 +6563,12 @@ const deserializeAws_json1_1ListUserPoolClientsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6526,8 +6600,7 @@ const deserializeAws_json1_1ListUserPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6543,10 +6616,12 @@ const deserializeAws_json1_1ListUserPoolsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6578,8 +6653,7 @@ const deserializeAws_json1_1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6598,10 +6672,12 @@ const deserializeAws_json1_1ListUsersCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6633,8 +6709,7 @@ const deserializeAws_json1_1ListUsersInGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6653,10 +6728,12 @@ const deserializeAws_json1_1ListUsersInGroupCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6688,8 +6765,7 @@ const deserializeAws_json1_1ResendConfirmationCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -6735,10 +6811,12 @@ const deserializeAws_json1_1ResendConfirmationCodeCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6770,8 +6848,7 @@ const deserializeAws_json1_1RespondToAuthChallengeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -6835,10 +6912,12 @@ const deserializeAws_json1_1RespondToAuthChallengeCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6870,8 +6949,7 @@ const deserializeAws_json1_1RevokeTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -6893,10 +6971,12 @@ const deserializeAws_json1_1RevokeTokenCommandError = async ( throw await deserializeAws_json1_1UnsupportedTokenTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6928,8 +7008,7 @@ const deserializeAws_json1_1SetRiskConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -6957,10 +7036,12 @@ const deserializeAws_json1_1SetRiskConfigurationCommandError = async ( throw await deserializeAws_json1_1UserPoolAddOnNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6992,8 +7073,7 @@ const deserializeAws_json1_1SetUICustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7012,10 +7092,12 @@ const deserializeAws_json1_1SetUICustomizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7047,8 +7129,7 @@ const deserializeAws_json1_1SetUserMFAPreferenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7073,10 +7154,12 @@ const deserializeAws_json1_1SetUserMFAPreferenceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7108,8 +7191,7 @@ const deserializeAws_json1_1SetUserPoolMfaConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7134,10 +7216,12 @@ const deserializeAws_json1_1SetUserPoolMfaConfigCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7169,8 +7253,7 @@ const deserializeAws_json1_1SetUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7195,10 +7278,12 @@ const deserializeAws_json1_1SetUserSettingsCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7230,8 +7315,7 @@ const deserializeAws_json1_1SignUpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeDeliveryFailureException": case "com.amazonaws.cognitoidentityprovider#CodeDeliveryFailureException": @@ -7277,10 +7361,12 @@ const deserializeAws_json1_1SignUpCommandError = async ( throw await deserializeAws_json1_1UsernameExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7312,8 +7398,7 @@ const deserializeAws_json1_1StartUserImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7335,10 +7420,12 @@ const deserializeAws_json1_1StartUserImportJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7370,8 +7457,7 @@ const deserializeAws_json1_1StopUserImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7393,10 +7479,12 @@ const deserializeAws_json1_1StopUserImportJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7428,8 +7516,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7448,10 +7535,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7483,8 +7572,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7503,10 +7591,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7538,8 +7628,7 @@ const deserializeAws_json1_1UpdateAuthEventFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7564,10 +7653,12 @@ const deserializeAws_json1_1UpdateAuthEventFeedbackCommandError = async ( throw await deserializeAws_json1_1UserPoolAddOnNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7599,8 +7690,7 @@ const deserializeAws_json1_1UpdateDeviceStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7631,10 +7721,12 @@ const deserializeAws_json1_1UpdateDeviceStatusCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7666,8 +7758,7 @@ const deserializeAws_json1_1UpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7686,10 +7777,12 @@ const deserializeAws_json1_1UpdateGroupCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7721,8 +7814,7 @@ const deserializeAws_json1_1UpdateIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7744,10 +7836,12 @@ const deserializeAws_json1_1UpdateIdentityProviderCommandError = async ( throw await deserializeAws_json1_1UnsupportedIdentityProviderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7779,8 +7873,7 @@ const deserializeAws_json1_1UpdateResourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -7799,10 +7892,12 @@ const deserializeAws_json1_1UpdateResourceServerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7834,8 +7929,7 @@ const deserializeAws_json1_1UpdateUserAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -7893,10 +7987,12 @@ const deserializeAws_json1_1UpdateUserAttributesCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7928,8 +8024,7 @@ const deserializeAws_json1_1UpdateUserPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitoidentityprovider#ConcurrentModificationException": @@ -7966,10 +8061,12 @@ const deserializeAws_json1_1UpdateUserPoolCommandError = async ( throw await deserializeAws_json1_1UserPoolTaggingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8001,8 +8098,7 @@ const deserializeAws_json1_1UpdateUserPoolClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitoidentityprovider#ConcurrentModificationException": @@ -8030,10 +8126,12 @@ const deserializeAws_json1_1UpdateUserPoolClientCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8065,8 +8163,7 @@ const deserializeAws_json1_1UpdateUserPoolDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentityprovider#InternalErrorException": @@ -8085,10 +8182,12 @@ const deserializeAws_json1_1UpdateUserPoolDomainCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8120,8 +8219,7 @@ const deserializeAws_json1_1VerifySoftwareTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeMismatchException": case "com.amazonaws.cognitoidentityprovider#CodeMismatchException": @@ -8161,10 +8259,12 @@ const deserializeAws_json1_1VerifySoftwareTokenCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8196,8 +8296,7 @@ const deserializeAws_json1_1VerifyUserAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AliasExistsException": case "com.amazonaws.cognitoidentityprovider#AliasExistsException": @@ -8237,10 +8336,12 @@ const deserializeAws_json1_1VerifyUserAttributeCommandError = async ( throw await deserializeAws_json1_1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13862,7 +13963,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -13888,6 +13989,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cognito-identity/src/protocols/Aws_json1_1.ts b/clients/client-cognito-identity/src/protocols/Aws_json1_1.ts index 1c79b52561927..fdd09597ce9cd 100644 --- a/clients/client-cognito-identity/src/protocols/Aws_json1_1.ts +++ b/clients/client-cognito-identity/src/protocols/Aws_json1_1.ts @@ -457,8 +457,7 @@ const deserializeAws_json1_1CreateIdentityPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -480,10 +479,12 @@ const deserializeAws_json1_1CreateIdentityPoolCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -515,8 +516,7 @@ const deserializeAws_json1_1DeleteIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -529,10 +529,12 @@ const deserializeAws_json1_1DeleteIdentitiesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -561,8 +563,7 @@ const deserializeAws_json1_1DeleteIdentityPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -581,10 +582,12 @@ const deserializeAws_json1_1DeleteIdentityPoolCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -616,8 +619,7 @@ const deserializeAws_json1_1DescribeIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -636,10 +638,12 @@ const deserializeAws_json1_1DescribeIdentityCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -671,8 +675,7 @@ const deserializeAws_json1_1DescribeIdentityPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -691,10 +694,12 @@ const deserializeAws_json1_1DescribeIdentityPoolCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -726,8 +731,7 @@ const deserializeAws_json1_1GetCredentialsForIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExternalServiceException": case "com.amazonaws.cognitoidentity#ExternalServiceException": @@ -755,10 +759,12 @@ const deserializeAws_json1_1GetCredentialsForIdentityCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -790,8 +796,7 @@ const deserializeAws_json1_1GetIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExternalServiceException": case "com.amazonaws.cognitoidentity#ExternalServiceException": @@ -819,10 +824,12 @@ const deserializeAws_json1_1GetIdCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -854,8 +861,7 @@ const deserializeAws_json1_1GetIdentityPoolRolesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -877,10 +883,12 @@ const deserializeAws_json1_1GetIdentityPoolRolesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -912,8 +920,7 @@ const deserializeAws_json1_1GetOpenIdTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExternalServiceException": case "com.amazonaws.cognitoidentity#ExternalServiceException": @@ -938,10 +945,12 @@ const deserializeAws_json1_1GetOpenIdTokenCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -973,8 +982,7 @@ const deserializeAws_json1_1GetOpenIdTokenForDeveloperIdentityCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeveloperUserAlreadyRegisteredException": case "com.amazonaws.cognitoidentity#DeveloperUserAlreadyRegisteredException": @@ -999,10 +1007,12 @@ const deserializeAws_json1_1GetOpenIdTokenForDeveloperIdentityCommandError = asy throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1034,8 +1044,7 @@ const deserializeAws_json1_1GetPrincipalTagAttributeMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1054,10 +1063,12 @@ const deserializeAws_json1_1GetPrincipalTagAttributeMapCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1089,8 +1100,7 @@ const deserializeAws_json1_1ListIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1109,10 +1119,12 @@ const deserializeAws_json1_1ListIdentitiesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1144,8 +1156,7 @@ const deserializeAws_json1_1ListIdentityPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1164,10 +1175,12 @@ const deserializeAws_json1_1ListIdentityPoolsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1199,8 +1212,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1219,10 +1231,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,8 +1268,7 @@ const deserializeAws_json1_1LookupDeveloperIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1277,10 +1290,12 @@ const deserializeAws_json1_1LookupDeveloperIdentityCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1312,8 +1327,7 @@ const deserializeAws_json1_1MergeDeveloperIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1335,10 +1349,12 @@ const deserializeAws_json1_1MergeDeveloperIdentitiesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1367,8 +1383,7 @@ const deserializeAws_json1_1SetIdentityPoolRolesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitoidentity#ConcurrentModificationException": @@ -1393,10 +1408,12 @@ const deserializeAws_json1_1SetIdentityPoolRolesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1428,8 +1445,7 @@ const deserializeAws_json1_1SetPrincipalTagAttributeMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1448,10 +1464,12 @@ const deserializeAws_json1_1SetPrincipalTagAttributeMapCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1483,8 +1501,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1503,10 +1520,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1535,8 +1554,7 @@ const deserializeAws_json1_1UnlinkDeveloperIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1558,10 +1576,12 @@ const deserializeAws_json1_1UnlinkDeveloperIdentityCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1590,8 +1610,7 @@ const deserializeAws_json1_1UnlinkIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExternalServiceException": case "com.amazonaws.cognitoidentity#ExternalServiceException": @@ -1616,10 +1635,12 @@ const deserializeAws_json1_1UnlinkIdentityCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1672,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitoidentity#InternalErrorException": @@ -1671,10 +1691,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1706,8 +1728,7 @@ const deserializeAws_json1_1UpdateIdentityPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitoidentity#ConcurrentModificationException": @@ -1735,10 +1756,12 @@ const deserializeAws_json1_1UpdateIdentityPoolCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2988,7 +3011,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3014,6 +3037,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cognito-sync/src/protocols/Aws_restJson1.ts b/clients/client-cognito-sync/src/protocols/Aws_restJson1.ts index 740a1c5f77b5d..35d891a987317 100644 --- a/clients/client-cognito-sync/src/protocols/Aws_restJson1.ts +++ b/clients/client-cognito-sync/src/protocols/Aws_restJson1.ts @@ -807,8 +807,7 @@ const deserializeAws_restJson1BulkPublishCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyStreamedException": case "com.amazonaws.cognitosync#AlreadyStreamedException": @@ -830,10 +829,12 @@ const deserializeAws_restJson1BulkPublishCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -866,8 +867,7 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -889,10 +889,12 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -925,8 +927,7 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -945,10 +946,12 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -981,8 +984,7 @@ const deserializeAws_restJson1DescribeIdentityPoolUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1001,10 +1003,12 @@ const deserializeAws_restJson1DescribeIdentityPoolUsageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1037,8 +1041,7 @@ const deserializeAws_restJson1DescribeIdentityUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1057,10 +1060,12 @@ const deserializeAws_restJson1DescribeIdentityUsageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1111,8 +1116,7 @@ const deserializeAws_restJson1GetBulkPublishDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1128,10 +1132,12 @@ const deserializeAws_restJson1GetBulkPublishDetailsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1164,8 +1170,7 @@ const deserializeAws_restJson1GetCognitoEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1184,10 +1189,12 @@ const deserializeAws_restJson1GetCognitoEventsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1228,8 +1235,7 @@ const deserializeAws_restJson1GetIdentityPoolConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1248,10 +1254,12 @@ const deserializeAws_restJson1GetIdentityPoolConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1292,8 +1300,7 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1309,10 +1316,12 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1357,8 +1366,7 @@ const deserializeAws_restJson1ListIdentityPoolUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1374,10 +1382,12 @@ const deserializeAws_restJson1ListIdentityPoolUsageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1442,8 +1452,7 @@ const deserializeAws_restJson1ListRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1459,10 +1468,12 @@ const deserializeAws_restJson1ListRecordsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1495,8 +1506,7 @@ const deserializeAws_restJson1RegisterDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1518,10 +1528,12 @@ const deserializeAws_restJson1RegisterDeviceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1550,8 +1562,7 @@ const deserializeAws_restJson1SetCognitoEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1570,10 +1581,12 @@ const deserializeAws_restJson1SetCognitoEventsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1614,8 +1627,7 @@ const deserializeAws_restJson1SetIdentityPoolConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.cognitosync#ConcurrentModificationException": @@ -1637,10 +1649,12 @@ const deserializeAws_restJson1SetIdentityPoolConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1669,8 +1683,7 @@ const deserializeAws_restJson1SubscribeToDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1692,10 +1705,12 @@ const deserializeAws_restJson1SubscribeToDatasetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1724,8 +1739,7 @@ const deserializeAws_restJson1UnsubscribeFromDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1747,10 +1761,12 @@ const deserializeAws_restJson1UnsubscribeFromDatasetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1783,8 +1799,7 @@ const deserializeAws_restJson1UpdateRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.cognitosync#InternalErrorException": @@ -1815,10 +1830,12 @@ const deserializeAws_restJson1UpdateRecordsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2285,7 +2302,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2311,6 +2328,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-comprehend/src/protocols/Aws_json1_1.ts b/clients/client-comprehend/src/protocols/Aws_json1_1.ts index edf2443b62582..ea225a9b445b9 100644 --- a/clients/client-comprehend/src/protocols/Aws_json1_1.ts +++ b/clients/client-comprehend/src/protocols/Aws_json1_1.ts @@ -1430,8 +1430,7 @@ const deserializeAws_json1_1BatchDetectDominantLanguageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchSizeLimitExceededException": case "com.amazonaws.comprehend#BatchSizeLimitExceededException": @@ -1447,10 +1446,12 @@ const deserializeAws_json1_1BatchDetectDominantLanguageCommandError = async ( throw await deserializeAws_json1_1TextSizeLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1482,8 +1483,7 @@ const deserializeAws_json1_1BatchDetectEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchSizeLimitExceededException": case "com.amazonaws.comprehend#BatchSizeLimitExceededException": @@ -1502,10 +1502,12 @@ const deserializeAws_json1_1BatchDetectEntitiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1537,8 +1539,7 @@ const deserializeAws_json1_1BatchDetectKeyPhrasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchSizeLimitExceededException": case "com.amazonaws.comprehend#BatchSizeLimitExceededException": @@ -1557,10 +1558,12 @@ const deserializeAws_json1_1BatchDetectKeyPhrasesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1592,8 +1595,7 @@ const deserializeAws_json1_1BatchDetectSentimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchSizeLimitExceededException": case "com.amazonaws.comprehend#BatchSizeLimitExceededException": @@ -1612,10 +1614,12 @@ const deserializeAws_json1_1BatchDetectSentimentCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1647,8 +1651,7 @@ const deserializeAws_json1_1BatchDetectSyntaxCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchSizeLimitExceededException": case "com.amazonaws.comprehend#BatchSizeLimitExceededException": @@ -1667,10 +1670,12 @@ const deserializeAws_json1_1BatchDetectSyntaxCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1702,8 +1707,7 @@ const deserializeAws_json1_1ClassifyDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -1719,10 +1723,12 @@ const deserializeAws_json1_1ClassifyDocumentCommandError = async ( throw await deserializeAws_json1_1TextSizeLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1754,8 +1760,7 @@ const deserializeAws_json1_1ContainsPiiEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -1771,10 +1776,12 @@ const deserializeAws_json1_1ContainsPiiEntitiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1806,8 +1813,7 @@ const deserializeAws_json1_1CreateDocumentClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -1835,10 +1841,12 @@ const deserializeAws_json1_1CreateDocumentClassifierCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1870,8 +1878,7 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -1899,10 +1906,12 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1934,8 +1943,7 @@ const deserializeAws_json1_1CreateEntityRecognizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -1963,10 +1971,12 @@ const deserializeAws_json1_1CreateEntityRecognizerCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1998,8 +2008,7 @@ const deserializeAws_json1_1DeleteDocumentClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2021,10 +2030,12 @@ const deserializeAws_json1_1DeleteDocumentClassifierCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2056,8 +2067,7 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2076,10 +2086,12 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2111,8 +2123,7 @@ const deserializeAws_json1_1DeleteEntityRecognizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2134,10 +2145,12 @@ const deserializeAws_json1_1DeleteEntityRecognizerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2169,8 +2182,7 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2183,10 +2195,12 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2218,8 +2232,7 @@ const deserializeAws_json1_1DescribeDocumentClassificationJobCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2235,10 +2248,12 @@ const deserializeAws_json1_1DescribeDocumentClassificationJobCommandError = asyn throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2270,8 +2285,7 @@ const deserializeAws_json1_1DescribeDocumentClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2287,10 +2301,12 @@ const deserializeAws_json1_1DescribeDocumentClassifierCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2322,8 +2338,7 @@ const deserializeAws_json1_1DescribeDominantLanguageDetectionJobCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2339,10 +2354,12 @@ const deserializeAws_json1_1DescribeDominantLanguageDetectionJobCommandError = a throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2374,8 +2391,7 @@ const deserializeAws_json1_1DescribeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2391,10 +2407,12 @@ const deserializeAws_json1_1DescribeEndpointCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2426,8 +2444,7 @@ const deserializeAws_json1_1DescribeEntitiesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2443,10 +2460,12 @@ const deserializeAws_json1_1DescribeEntitiesDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2478,8 +2497,7 @@ const deserializeAws_json1_1DescribeEntityRecognizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2495,10 +2513,12 @@ const deserializeAws_json1_1DescribeEntityRecognizerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2530,8 +2550,7 @@ const deserializeAws_json1_1DescribeEventsDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2547,10 +2566,12 @@ const deserializeAws_json1_1DescribeEventsDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2582,8 +2603,7 @@ const deserializeAws_json1_1DescribeKeyPhrasesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2599,10 +2619,12 @@ const deserializeAws_json1_1DescribeKeyPhrasesDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2634,8 +2656,7 @@ const deserializeAws_json1_1DescribePiiEntitiesDetectionJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2651,10 +2672,12 @@ const deserializeAws_json1_1DescribePiiEntitiesDetectionJobCommandError = async throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2686,8 +2709,7 @@ const deserializeAws_json1_1DescribeResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2700,10 +2722,12 @@ const deserializeAws_json1_1DescribeResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2735,8 +2759,7 @@ const deserializeAws_json1_1DescribeSentimentDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2752,10 +2775,12 @@ const deserializeAws_json1_1DescribeSentimentDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2787,8 +2812,7 @@ const deserializeAws_json1_1DescribeTargetedSentimentDetectionJobCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2804,10 +2828,12 @@ const deserializeAws_json1_1DescribeTargetedSentimentDetectionJobCommandError = throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2839,8 +2865,7 @@ const deserializeAws_json1_1DescribeTopicsDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2856,10 +2881,12 @@ const deserializeAws_json1_1DescribeTopicsDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2891,8 +2918,7 @@ const deserializeAws_json1_1DetectDominantLanguageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2905,10 +2931,12 @@ const deserializeAws_json1_1DetectDominantLanguageCommandError = async ( throw await deserializeAws_json1_1TextSizeLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2940,8 +2968,7 @@ const deserializeAws_json1_1DetectEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -2960,10 +2987,12 @@ const deserializeAws_json1_1DetectEntitiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2995,8 +3024,7 @@ const deserializeAws_json1_1DetectKeyPhrasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3012,10 +3040,12 @@ const deserializeAws_json1_1DetectKeyPhrasesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3047,8 +3077,7 @@ const deserializeAws_json1_1DetectPiiEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3064,10 +3093,12 @@ const deserializeAws_json1_1DetectPiiEntitiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3099,8 +3130,7 @@ const deserializeAws_json1_1DetectSentimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3116,10 +3146,12 @@ const deserializeAws_json1_1DetectSentimentCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3151,8 +3183,7 @@ const deserializeAws_json1_1DetectSyntaxCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3168,10 +3199,12 @@ const deserializeAws_json1_1DetectSyntaxCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3203,8 +3236,7 @@ const deserializeAws_json1_1ImportModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3235,10 +3267,12 @@ const deserializeAws_json1_1ImportModelCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3270,8 +3304,7 @@ const deserializeAws_json1_1ListDocumentClassificationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3287,10 +3320,12 @@ const deserializeAws_json1_1ListDocumentClassificationJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3322,8 +3357,7 @@ const deserializeAws_json1_1ListDocumentClassifiersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3339,10 +3373,12 @@ const deserializeAws_json1_1ListDocumentClassifiersCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3374,8 +3410,7 @@ const deserializeAws_json1_1ListDocumentClassifierSummariesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3388,10 +3423,12 @@ const deserializeAws_json1_1ListDocumentClassifierSummariesCommandError = async throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3423,8 +3460,7 @@ const deserializeAws_json1_1ListDominantLanguageDetectionJobsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3440,10 +3476,12 @@ const deserializeAws_json1_1ListDominantLanguageDetectionJobsCommandError = asyn throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3475,8 +3513,7 @@ const deserializeAws_json1_1ListEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3489,10 +3526,12 @@ const deserializeAws_json1_1ListEndpointsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3524,8 +3563,7 @@ const deserializeAws_json1_1ListEntitiesDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3541,10 +3579,12 @@ const deserializeAws_json1_1ListEntitiesDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3576,8 +3616,7 @@ const deserializeAws_json1_1ListEntityRecognizersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3593,10 +3632,12 @@ const deserializeAws_json1_1ListEntityRecognizersCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3628,8 +3669,7 @@ const deserializeAws_json1_1ListEntityRecognizerSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3642,10 +3682,12 @@ const deserializeAws_json1_1ListEntityRecognizerSummariesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3677,8 +3719,7 @@ const deserializeAws_json1_1ListEventsDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3694,10 +3735,12 @@ const deserializeAws_json1_1ListEventsDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3729,8 +3772,7 @@ const deserializeAws_json1_1ListKeyPhrasesDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3746,10 +3788,12 @@ const deserializeAws_json1_1ListKeyPhrasesDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3781,8 +3825,7 @@ const deserializeAws_json1_1ListPiiEntitiesDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3798,10 +3841,12 @@ const deserializeAws_json1_1ListPiiEntitiesDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3833,8 +3878,7 @@ const deserializeAws_json1_1ListSentimentDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3850,10 +3894,12 @@ const deserializeAws_json1_1ListSentimentDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3885,8 +3931,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3899,10 +3944,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3934,8 +3981,7 @@ const deserializeAws_json1_1ListTargetedSentimentDetectionJobsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -3951,10 +3997,12 @@ const deserializeAws_json1_1ListTargetedSentimentDetectionJobsCommandError = asy throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3986,8 +4034,7 @@ const deserializeAws_json1_1ListTopicsDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4003,10 +4050,12 @@ const deserializeAws_json1_1ListTopicsDetectionJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4038,8 +4087,7 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4052,10 +4100,12 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4087,8 +4137,7 @@ const deserializeAws_json1_1StartDocumentClassificationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4113,10 +4162,12 @@ const deserializeAws_json1_1StartDocumentClassificationJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4148,8 +4199,7 @@ const deserializeAws_json1_1StartDominantLanguageDetectionJobCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4168,10 +4218,12 @@ const deserializeAws_json1_1StartDominantLanguageDetectionJobCommandError = asyn throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4203,8 +4255,7 @@ const deserializeAws_json1_1StartEntitiesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4229,10 +4280,12 @@ const deserializeAws_json1_1StartEntitiesDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4264,8 +4317,7 @@ const deserializeAws_json1_1StartEventsDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4284,10 +4336,12 @@ const deserializeAws_json1_1StartEventsDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4319,8 +4373,7 @@ const deserializeAws_json1_1StartKeyPhrasesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4339,10 +4392,12 @@ const deserializeAws_json1_1StartKeyPhrasesDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4374,8 +4429,7 @@ const deserializeAws_json1_1StartPiiEntitiesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4394,10 +4448,12 @@ const deserializeAws_json1_1StartPiiEntitiesDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4429,8 +4485,7 @@ const deserializeAws_json1_1StartSentimentDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4449,10 +4504,12 @@ const deserializeAws_json1_1StartSentimentDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4484,8 +4541,7 @@ const deserializeAws_json1_1StartTargetedSentimentDetectionJobCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4504,10 +4560,12 @@ const deserializeAws_json1_1StartTargetedSentimentDetectionJobCommandError = asy throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4539,8 +4597,7 @@ const deserializeAws_json1_1StartTopicsDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4559,10 +4616,12 @@ const deserializeAws_json1_1StartTopicsDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4594,8 +4653,7 @@ const deserializeAws_json1_1StopDominantLanguageDetectionJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4608,10 +4666,12 @@ const deserializeAws_json1_1StopDominantLanguageDetectionJobCommandError = async throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4643,8 +4703,7 @@ const deserializeAws_json1_1StopEntitiesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4657,10 +4716,12 @@ const deserializeAws_json1_1StopEntitiesDetectionJobCommandError = async ( throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4692,8 +4753,7 @@ const deserializeAws_json1_1StopEventsDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4706,10 +4766,12 @@ const deserializeAws_json1_1StopEventsDetectionJobCommandError = async ( throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4741,8 +4803,7 @@ const deserializeAws_json1_1StopKeyPhrasesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4755,10 +4816,12 @@ const deserializeAws_json1_1StopKeyPhrasesDetectionJobCommandError = async ( throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4790,8 +4853,7 @@ const deserializeAws_json1_1StopPiiEntitiesDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4804,10 +4866,12 @@ const deserializeAws_json1_1StopPiiEntitiesDetectionJobCommandError = async ( throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4839,8 +4903,7 @@ const deserializeAws_json1_1StopSentimentDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4853,10 +4916,12 @@ const deserializeAws_json1_1StopSentimentDetectionJobCommandError = async ( throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4888,8 +4953,7 @@ const deserializeAws_json1_1StopTargetedSentimentDetectionJobCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4902,10 +4966,12 @@ const deserializeAws_json1_1StopTargetedSentimentDetectionJobCommandError = asyn throw await deserializeAws_json1_1JobNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4937,8 +5003,7 @@ const deserializeAws_json1_1StopTrainingDocumentClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -4954,10 +5019,12 @@ const deserializeAws_json1_1StopTrainingDocumentClassifierCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4989,8 +5056,7 @@ const deserializeAws_json1_1StopTrainingEntityRecognizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -5006,10 +5072,12 @@ const deserializeAws_json1_1StopTrainingEntityRecognizerCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5041,8 +5109,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.comprehend#ConcurrentModificationException": @@ -5061,10 +5128,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5096,8 +5165,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.comprehend#ConcurrentModificationException": @@ -5116,10 +5184,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagKeysExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5151,8 +5221,7 @@ const deserializeAws_json1_1UpdateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehend#InternalServerException": @@ -5177,10 +5246,12 @@ const deserializeAws_json1_1UpdateEndpointCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9193,7 +9264,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9219,6 +9290,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-comprehendmedical/src/protocols/Aws_json1_1.ts b/clients/client-comprehendmedical/src/protocols/Aws_json1_1.ts index 9ef71e041115b..7883f701678a8 100644 --- a/clients/client-comprehendmedical/src/protocols/Aws_json1_1.ts +++ b/clients/client-comprehendmedical/src/protocols/Aws_json1_1.ts @@ -553,8 +553,7 @@ const deserializeAws_json1_1DescribeEntitiesDetectionV2JobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -570,10 +569,12 @@ const deserializeAws_json1_1DescribeEntitiesDetectionV2JobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -605,8 +606,7 @@ const deserializeAws_json1_1DescribeICD10CMInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -622,10 +622,12 @@ const deserializeAws_json1_1DescribeICD10CMInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -657,8 +659,7 @@ const deserializeAws_json1_1DescribePHIDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -674,10 +675,12 @@ const deserializeAws_json1_1DescribePHIDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -709,8 +712,7 @@ const deserializeAws_json1_1DescribeRxNormInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -726,10 +728,12 @@ const deserializeAws_json1_1DescribeRxNormInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -761,8 +765,7 @@ const deserializeAws_json1_1DescribeSNOMEDCTInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -778,10 +781,12 @@ const deserializeAws_json1_1DescribeSNOMEDCTInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -813,8 +818,7 @@ const deserializeAws_json1_1DetectEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -836,10 +840,12 @@ const deserializeAws_json1_1DetectEntitiesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -871,8 +877,7 @@ const deserializeAws_json1_1DetectEntitiesV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -894,10 +899,12 @@ const deserializeAws_json1_1DetectEntitiesV2CommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -929,8 +936,7 @@ const deserializeAws_json1_1DetectPHICommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -952,10 +958,12 @@ const deserializeAws_json1_1DetectPHICommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -987,8 +995,7 @@ const deserializeAws_json1_1InferICD10CMCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1010,10 +1017,12 @@ const deserializeAws_json1_1InferICD10CMCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1045,8 +1054,7 @@ const deserializeAws_json1_1InferRxNormCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1068,10 +1076,12 @@ const deserializeAws_json1_1InferRxNormCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1103,8 +1113,7 @@ const deserializeAws_json1_1InferSNOMEDCTCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1126,10 +1135,12 @@ const deserializeAws_json1_1InferSNOMEDCTCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1161,8 +1172,7 @@ const deserializeAws_json1_1ListEntitiesDetectionV2JobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1178,10 +1188,12 @@ const deserializeAws_json1_1ListEntitiesDetectionV2JobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1213,8 +1225,7 @@ const deserializeAws_json1_1ListICD10CMInferenceJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1230,10 +1241,12 @@ const deserializeAws_json1_1ListICD10CMInferenceJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1265,8 +1278,7 @@ const deserializeAws_json1_1ListPHIDetectionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1282,10 +1294,12 @@ const deserializeAws_json1_1ListPHIDetectionJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1317,8 +1331,7 @@ const deserializeAws_json1_1ListRxNormInferenceJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1334,10 +1347,12 @@ const deserializeAws_json1_1ListRxNormInferenceJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1369,8 +1384,7 @@ const deserializeAws_json1_1ListSNOMEDCTInferenceJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1386,10 +1400,12 @@ const deserializeAws_json1_1ListSNOMEDCTInferenceJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1421,8 +1437,7 @@ const deserializeAws_json1_1StartEntitiesDetectionV2JobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1438,10 +1453,12 @@ const deserializeAws_json1_1StartEntitiesDetectionV2JobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1473,8 +1490,7 @@ const deserializeAws_json1_1StartICD10CMInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1490,10 +1506,12 @@ const deserializeAws_json1_1StartICD10CMInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1525,8 +1543,7 @@ const deserializeAws_json1_1StartPHIDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1542,10 +1559,12 @@ const deserializeAws_json1_1StartPHIDetectionJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1596,7 @@ const deserializeAws_json1_1StartRxNormInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1594,10 +1612,12 @@ const deserializeAws_json1_1StartRxNormInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1629,8 +1649,7 @@ const deserializeAws_json1_1StartSNOMEDCTInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1646,10 +1665,12 @@ const deserializeAws_json1_1StartSNOMEDCTInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1681,8 +1702,7 @@ const deserializeAws_json1_1StopEntitiesDetectionV2JobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1695,10 +1715,12 @@ const deserializeAws_json1_1StopEntitiesDetectionV2JobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1730,8 +1752,7 @@ const deserializeAws_json1_1StopICD10CMInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1744,10 +1765,12 @@ const deserializeAws_json1_1StopICD10CMInferenceJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1779,8 +1802,7 @@ const deserializeAws_json1_1StopPHIDetectionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1793,10 +1815,12 @@ const deserializeAws_json1_1StopPHIDetectionJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1828,8 +1852,7 @@ const deserializeAws_json1_1StopRxNormInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1842,10 +1865,12 @@ const deserializeAws_json1_1StopRxNormInferenceJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1877,8 +1902,7 @@ const deserializeAws_json1_1StopSNOMEDCTInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.comprehendmedical#InternalServerException": @@ -1894,10 +1918,12 @@ const deserializeAws_json1_1StopSNOMEDCTInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3275,7 +3301,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3301,6 +3327,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-compute-optimizer/src/protocols/Aws_json1_0.ts b/clients/client-compute-optimizer/src/protocols/Aws_json1_0.ts index cbaf8f9b22fc5..bc0f37c93ff89 100644 --- a/clients/client-compute-optimizer/src/protocols/Aws_json1_0.ts +++ b/clients/client-compute-optimizer/src/protocols/Aws_json1_0.ts @@ -447,8 +447,7 @@ const deserializeAws_json1_0DeleteRecommendationPreferencesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -476,10 +475,12 @@ const deserializeAws_json1_0DeleteRecommendationPreferencesCommandError = async throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -511,8 +512,7 @@ const deserializeAws_json1_0DescribeRecommendationExportJobsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -540,10 +540,12 @@ const deserializeAws_json1_0DescribeRecommendationExportJobsCommandError = async throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -575,8 +577,7 @@ const deserializeAws_json1_0ExportAutoScalingGroupRecommendationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -604,10 +605,12 @@ const deserializeAws_json1_0ExportAutoScalingGroupRecommendationsCommandError = throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -639,8 +642,7 @@ const deserializeAws_json1_0ExportEBSVolumeRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -668,10 +670,12 @@ const deserializeAws_json1_0ExportEBSVolumeRecommendationsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -703,8 +707,7 @@ const deserializeAws_json1_0ExportEC2InstanceRecommendationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -732,10 +735,12 @@ const deserializeAws_json1_0ExportEC2InstanceRecommendationsCommandError = async throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -767,8 +772,7 @@ const deserializeAws_json1_0ExportLambdaFunctionRecommendationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -796,10 +800,12 @@ const deserializeAws_json1_0ExportLambdaFunctionRecommendationsCommandError = as throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -831,8 +837,7 @@ const deserializeAws_json1_0GetAutoScalingGroupRecommendationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -860,10 +865,12 @@ const deserializeAws_json1_0GetAutoScalingGroupRecommendationsCommandError = asy throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -895,8 +902,7 @@ const deserializeAws_json1_0GetEBSVolumeRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -924,10 +930,12 @@ const deserializeAws_json1_0GetEBSVolumeRecommendationsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,8 +967,7 @@ const deserializeAws_json1_0GetEC2InstanceRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -988,10 +995,12 @@ const deserializeAws_json1_0GetEC2InstanceRecommendationsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1023,8 +1032,7 @@ const deserializeAws_json1_0GetEC2RecommendationProjectedMetricsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1052,10 +1060,12 @@ const deserializeAws_json1_0GetEC2RecommendationProjectedMetricsCommandError = a throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1087,8 +1097,7 @@ const deserializeAws_json1_0GetEffectiveRecommendationPreferencesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1116,10 +1125,12 @@ const deserializeAws_json1_0GetEffectiveRecommendationPreferencesCommandError = throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1151,8 +1162,7 @@ const deserializeAws_json1_0GetEnrollmentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1174,10 +1184,12 @@ const deserializeAws_json1_0GetEnrollmentStatusCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1221,7 @@ const deserializeAws_json1_0GetEnrollmentStatusesForOrganizationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1232,10 +1243,12 @@ const deserializeAws_json1_0GetEnrollmentStatusesForOrganizationCommandError = a throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1267,8 +1280,7 @@ const deserializeAws_json1_0GetLambdaFunctionRecommendationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1296,10 +1308,12 @@ const deserializeAws_json1_0GetLambdaFunctionRecommendationsCommandError = async throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1331,8 +1345,7 @@ const deserializeAws_json1_0GetRecommendationPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1360,10 +1373,12 @@ const deserializeAws_json1_0GetRecommendationPreferencesCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1395,8 +1410,7 @@ const deserializeAws_json1_0GetRecommendationSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1421,10 +1435,12 @@ const deserializeAws_json1_0GetRecommendationSummariesCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1456,8 +1472,7 @@ const deserializeAws_json1_0PutRecommendationPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1485,10 +1500,12 @@ const deserializeAws_json1_0PutRecommendationPreferencesCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1520,8 +1537,7 @@ const deserializeAws_json1_0UpdateEnrollmentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.computeoptimizer#AccessDeniedException": @@ -1543,10 +1559,12 @@ const deserializeAws_json1_0UpdateEnrollmentStatusCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3545,7 +3563,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3571,6 +3589,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-config-service/src/protocols/Aws_json1_1.ts b/clients/client-config-service/src/protocols/Aws_json1_1.ts index ee2d4eee3c231..a9308042c49bb 100644 --- a/clients/client-config-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-config-service/src/protocols/Aws_json1_1.ts @@ -1813,8 +1813,7 @@ const deserializeAws_json1_1BatchGetAggregateResourceConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationAggregatorException": case "com.amazonaws.configservice#NoSuchConfigurationAggregatorException": @@ -1824,10 +1823,12 @@ const deserializeAws_json1_1BatchGetAggregateResourceConfigCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1859,8 +1860,7 @@ const deserializeAws_json1_1BatchGetResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoAvailableConfigurationRecorderException": case "com.amazonaws.configservice#NoAvailableConfigurationRecorderException": @@ -1870,10 +1870,12 @@ const deserializeAws_json1_1BatchGetResourceConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1902,18 +1904,19 @@ const deserializeAws_json1_1DeleteAggregationAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1942,8 +1945,7 @@ const deserializeAws_json1_1DeleteConfigRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigRuleException": case "com.amazonaws.configservice#NoSuchConfigRuleException": @@ -1953,10 +1955,12 @@ const deserializeAws_json1_1DeleteConfigRuleCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1985,18 +1989,19 @@ const deserializeAws_json1_1DeleteConfigurationAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationAggregatorException": case "com.amazonaws.configservice#NoSuchConfigurationAggregatorException": throw await deserializeAws_json1_1NoSuchConfigurationAggregatorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2025,18 +2030,19 @@ const deserializeAws_json1_1DeleteConfigurationRecorderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationRecorderException": case "com.amazonaws.configservice#NoSuchConfigurationRecorderException": throw await deserializeAws_json1_1NoSuchConfigurationRecorderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2065,8 +2071,7 @@ const deserializeAws_json1_1DeleteConformancePackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConformancePackException": case "com.amazonaws.configservice#NoSuchConformancePackException": @@ -2076,10 +2081,12 @@ const deserializeAws_json1_1DeleteConformancePackCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2108,8 +2115,7 @@ const deserializeAws_json1_1DeleteDeliveryChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LastDeliveryChannelDeleteFailedException": case "com.amazonaws.configservice#LastDeliveryChannelDeleteFailedException": @@ -2119,10 +2125,12 @@ const deserializeAws_json1_1DeleteDeliveryChannelCommandError = async ( throw await deserializeAws_json1_1NoSuchDeliveryChannelExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2154,8 +2162,7 @@ const deserializeAws_json1_1DeleteEvaluationResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigRuleException": case "com.amazonaws.configservice#NoSuchConfigRuleException": @@ -2165,10 +2172,12 @@ const deserializeAws_json1_1DeleteEvaluationResultsCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2197,8 +2206,7 @@ const deserializeAws_json1_1DeleteOrganizationConfigRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchOrganizationConfigRuleException": case "com.amazonaws.configservice#NoSuchOrganizationConfigRuleException": @@ -2211,10 +2219,12 @@ const deserializeAws_json1_1DeleteOrganizationConfigRuleCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2243,8 +2253,7 @@ const deserializeAws_json1_1DeleteOrganizationConformancePackCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchOrganizationConformancePackException": case "com.amazonaws.configservice#NoSuchOrganizationConformancePackException": @@ -2257,10 +2266,12 @@ const deserializeAws_json1_1DeleteOrganizationConformancePackCommandError = asyn throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2289,18 +2300,19 @@ const deserializeAws_json1_1DeletePendingAggregationRequestCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2332,8 +2344,7 @@ const deserializeAws_json1_1DeleteRemediationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -2349,10 +2360,12 @@ const deserializeAws_json1_1DeleteRemediationConfigurationCommandError = async ( throw await deserializeAws_json1_1RemediationInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2384,18 +2397,19 @@ const deserializeAws_json1_1DeleteRemediationExceptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchRemediationExceptionException": case "com.amazonaws.configservice#NoSuchRemediationExceptionException": throw await deserializeAws_json1_1NoSuchRemediationExceptionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2424,8 +2438,7 @@ const deserializeAws_json1_1DeleteResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoRunningConfigurationRecorderException": case "com.amazonaws.configservice#NoRunningConfigurationRecorderException": @@ -2435,10 +2448,12 @@ const deserializeAws_json1_1DeleteResourceConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2467,8 +2482,7 @@ const deserializeAws_json1_1DeleteRetentionConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -2478,10 +2492,12 @@ const deserializeAws_json1_1DeleteRetentionConfigurationCommandError = async ( throw await deserializeAws_json1_1NoSuchRetentionConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2513,8 +2529,7 @@ const deserializeAws_json1_1DeleteStoredQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.configservice#ResourceNotFoundException": @@ -2524,10 +2539,12 @@ const deserializeAws_json1_1DeleteStoredQueryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2576,7 @@ const deserializeAws_json1_1DeliverConfigSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoAvailableConfigurationRecorderException": case "com.amazonaws.configservice#NoAvailableConfigurationRecorderException": @@ -2573,10 +2589,12 @@ const deserializeAws_json1_1DeliverConfigSnapshotCommandError = async ( throw await deserializeAws_json1_1NoSuchDeliveryChannelExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2608,8 +2626,7 @@ const deserializeAws_json1_1DescribeAggregateComplianceByConfigRulesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -2625,10 +2642,12 @@ const deserializeAws_json1_1DescribeAggregateComplianceByConfigRulesCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2660,8 +2679,7 @@ const deserializeAws_json1_1DescribeAggregateComplianceByConformancePacksCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -2677,10 +2695,12 @@ const deserializeAws_json1_1DescribeAggregateComplianceByConformancePacksCommand throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2712,8 +2732,7 @@ const deserializeAws_json1_1DescribeAggregationAuthorizationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -2726,10 +2745,12 @@ const deserializeAws_json1_1DescribeAggregationAuthorizationsCommandError = asyn throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2761,8 +2782,7 @@ const deserializeAws_json1_1DescribeComplianceByConfigRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -2775,10 +2795,12 @@ const deserializeAws_json1_1DescribeComplianceByConfigRuleCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2810,8 +2832,7 @@ const deserializeAws_json1_1DescribeComplianceByResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -2821,10 +2842,12 @@ const deserializeAws_json1_1DescribeComplianceByResourceCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2856,8 +2879,7 @@ const deserializeAws_json1_1DescribeConfigRuleEvaluationStatusCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -2870,10 +2892,12 @@ const deserializeAws_json1_1DescribeConfigRuleEvaluationStatusCommandError = asy throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2905,8 +2929,7 @@ const deserializeAws_json1_1DescribeConfigRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -2916,10 +2939,12 @@ const deserializeAws_json1_1DescribeConfigRulesCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2951,8 +2976,7 @@ const deserializeAws_json1_1DescribeConfigurationAggregatorsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -2968,10 +2992,12 @@ const deserializeAws_json1_1DescribeConfigurationAggregatorsCommandError = async throw await deserializeAws_json1_1NoSuchConfigurationAggregatorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3003,8 +3029,7 @@ const deserializeAws_json1_1DescribeConfigurationAggregatorSourcesStatusCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3020,10 +3045,12 @@ const deserializeAws_json1_1DescribeConfigurationAggregatorSourcesStatusCommandE throw await deserializeAws_json1_1NoSuchConfigurationAggregatorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3055,18 +3082,19 @@ const deserializeAws_json1_1DescribeConfigurationRecordersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationRecorderException": case "com.amazonaws.configservice#NoSuchConfigurationRecorderException": throw await deserializeAws_json1_1NoSuchConfigurationRecorderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3098,18 +3126,19 @@ const deserializeAws_json1_1DescribeConfigurationRecorderStatusCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationRecorderException": case "com.amazonaws.configservice#NoSuchConfigurationRecorderException": throw await deserializeAws_json1_1NoSuchConfigurationRecorderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3141,8 +3170,7 @@ const deserializeAws_json1_1DescribeConformancePackComplianceCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3161,10 +3189,12 @@ const deserializeAws_json1_1DescribeConformancePackComplianceCommandError = asyn throw await deserializeAws_json1_1NoSuchConformancePackExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3196,8 +3226,7 @@ const deserializeAws_json1_1DescribeConformancePacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3213,10 +3242,12 @@ const deserializeAws_json1_1DescribeConformancePacksCommandError = async ( throw await deserializeAws_json1_1NoSuchConformancePackExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3248,8 +3279,7 @@ const deserializeAws_json1_1DescribeConformancePackStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3262,10 +3292,12 @@ const deserializeAws_json1_1DescribeConformancePackStatusCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3297,18 +3329,19 @@ const deserializeAws_json1_1DescribeDeliveryChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchDeliveryChannelException": case "com.amazonaws.configservice#NoSuchDeliveryChannelException": throw await deserializeAws_json1_1NoSuchDeliveryChannelExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3340,18 +3373,19 @@ const deserializeAws_json1_1DescribeDeliveryChannelStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchDeliveryChannelException": case "com.amazonaws.configservice#NoSuchDeliveryChannelException": throw await deserializeAws_json1_1NoSuchDeliveryChannelExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3383,8 +3417,7 @@ const deserializeAws_json1_1DescribeOrganizationConfigRulesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3400,10 +3433,12 @@ const deserializeAws_json1_1DescribeOrganizationConfigRulesCommandError = async throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3435,8 +3470,7 @@ const deserializeAws_json1_1DescribeOrganizationConfigRuleStatusesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3452,10 +3486,12 @@ const deserializeAws_json1_1DescribeOrganizationConfigRuleStatusesCommandError = throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3487,8 +3523,7 @@ const deserializeAws_json1_1DescribeOrganizationConformancePacksCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3504,10 +3539,12 @@ const deserializeAws_json1_1DescribeOrganizationConformancePacksCommandError = a throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3539,8 +3576,7 @@ const deserializeAws_json1_1DescribeOrganizationConformancePackStatusesCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3556,10 +3592,12 @@ const deserializeAws_json1_1DescribeOrganizationConformancePackStatusesCommandEr throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3591,8 +3629,7 @@ const deserializeAws_json1_1DescribePendingAggregationRequestsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3605,10 +3642,12 @@ const deserializeAws_json1_1DescribePendingAggregationRequestsCommandError = asy throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3640,15 +3679,16 @@ const deserializeAws_json1_1DescribeRemediationConfigurationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3680,8 +3720,7 @@ const deserializeAws_json1_1DescribeRemediationExceptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -3691,10 +3730,12 @@ const deserializeAws_json1_1DescribeRemediationExceptionsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3726,8 +3767,7 @@ const deserializeAws_json1_1DescribeRemediationExecutionStatusCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -3740,10 +3780,12 @@ const deserializeAws_json1_1DescribeRemediationExecutionStatusCommandError = asy throw await deserializeAws_json1_1NoSuchRemediationConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3775,8 +3817,7 @@ const deserializeAws_json1_1DescribeRetentionConfigurationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -3789,10 +3830,12 @@ const deserializeAws_json1_1DescribeRetentionConfigurationsCommandError = async throw await deserializeAws_json1_1NoSuchRetentionConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3824,8 +3867,7 @@ const deserializeAws_json1_1GetAggregateComplianceDetailsByConfigRuleCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3841,10 +3883,12 @@ const deserializeAws_json1_1GetAggregateComplianceDetailsByConfigRuleCommandErro throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3876,8 +3920,7 @@ const deserializeAws_json1_1GetAggregateConfigRuleComplianceSummaryCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3893,10 +3936,12 @@ const deserializeAws_json1_1GetAggregateConfigRuleComplianceSummaryCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3928,8 +3973,7 @@ const deserializeAws_json1_1GetAggregateConformancePackComplianceSummaryCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3945,10 +3989,12 @@ const deserializeAws_json1_1GetAggregateConformancePackComplianceSummaryCommandE throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3980,8 +4026,7 @@ const deserializeAws_json1_1GetAggregateDiscoveredResourceCountsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -3997,10 +4042,12 @@ const deserializeAws_json1_1GetAggregateDiscoveredResourceCountsCommandError = a throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4032,8 +4079,7 @@ const deserializeAws_json1_1GetAggregateResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationAggregatorException": case "com.amazonaws.configservice#NoSuchConfigurationAggregatorException": @@ -4049,10 +4095,12 @@ const deserializeAws_json1_1GetAggregateResourceConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4084,8 +4132,7 @@ const deserializeAws_json1_1GetComplianceDetailsByConfigRuleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -4098,10 +4145,12 @@ const deserializeAws_json1_1GetComplianceDetailsByConfigRuleCommandError = async throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4133,18 +4182,19 @@ const deserializeAws_json1_1GetComplianceDetailsByResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4176,15 +4226,16 @@ const deserializeAws_json1_1GetComplianceSummaryByConfigRuleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4216,18 +4267,19 @@ const deserializeAws_json1_1GetComplianceSummaryByResourceTypeCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4259,8 +4311,7 @@ const deserializeAws_json1_1GetConformancePackComplianceDetailsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4279,10 +4330,12 @@ const deserializeAws_json1_1GetConformancePackComplianceDetailsCommandError = as throw await deserializeAws_json1_1NoSuchConformancePackExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4314,8 +4367,7 @@ const deserializeAws_json1_1GetConformancePackComplianceSummaryCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4328,10 +4380,12 @@ const deserializeAws_json1_1GetConformancePackComplianceSummaryCommandError = as throw await deserializeAws_json1_1NoSuchConformancePackExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4363,18 +4417,19 @@ const deserializeAws_json1_1GetCustomRulePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigRuleException": case "com.amazonaws.configservice#NoSuchConfigRuleException": throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4406,8 +4461,7 @@ const deserializeAws_json1_1GetDiscoveredResourceCountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4420,10 +4474,12 @@ const deserializeAws_json1_1GetDiscoveredResourceCountsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4455,8 +4511,7 @@ const deserializeAws_json1_1GetOrganizationConfigRuleDetailedStatusCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4472,10 +4527,12 @@ const deserializeAws_json1_1GetOrganizationConfigRuleDetailedStatusCommandError throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4507,8 +4564,7 @@ const deserializeAws_json1_1GetOrganizationConformancePackDetailedStatusCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4524,10 +4580,12 @@ const deserializeAws_json1_1GetOrganizationConformancePackDetailedStatusCommandE throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4559,8 +4617,7 @@ const deserializeAws_json1_1GetOrganizationCustomRulePolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchOrganizationConfigRuleException": case "com.amazonaws.configservice#NoSuchOrganizationConfigRuleException": @@ -4570,10 +4627,12 @@ const deserializeAws_json1_1GetOrganizationCustomRulePolicyCommandError = async throw await deserializeAws_json1_1OrganizationAccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4605,8 +4664,7 @@ const deserializeAws_json1_1GetResourceConfigHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4628,10 +4686,12 @@ const deserializeAws_json1_1GetResourceConfigHistoryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4663,8 +4723,7 @@ const deserializeAws_json1_1GetStoredQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.configservice#ResourceNotFoundException": @@ -4674,10 +4733,12 @@ const deserializeAws_json1_1GetStoredQueryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4709,8 +4770,7 @@ const deserializeAws_json1_1ListAggregateDiscoveredResourcesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4726,10 +4786,12 @@ const deserializeAws_json1_1ListAggregateDiscoveredResourcesCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4761,8 +4823,7 @@ const deserializeAws_json1_1ListDiscoveredResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4778,10 +4839,12 @@ const deserializeAws_json1_1ListDiscoveredResourcesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4813,8 +4876,7 @@ const deserializeAws_json1_1ListStoredQueriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.configservice#InvalidNextTokenException": @@ -4824,10 +4886,12 @@ const deserializeAws_json1_1ListStoredQueriesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4859,8 +4923,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLimitException": case "com.amazonaws.configservice#InvalidLimitException": @@ -4876,10 +4939,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4911,18 +4976,19 @@ const deserializeAws_json1_1PutAggregationAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4951,8 +5017,7 @@ const deserializeAws_json1_1PutConfigRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -4971,10 +5036,12 @@ const deserializeAws_json1_1PutConfigRuleCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5006,8 +5073,7 @@ const deserializeAws_json1_1PutConfigurationAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -5029,10 +5095,12 @@ const deserializeAws_json1_1PutConfigurationAggregatorCommandError = async ( throw await deserializeAws_json1_1OrganizationAllFeaturesNotEnabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5061,8 +5129,7 @@ const deserializeAws_json1_1PutConfigurationRecorderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRecorderNameException": case "com.amazonaws.configservice#InvalidConfigurationRecorderNameException": @@ -5081,10 +5148,12 @@ const deserializeAws_json1_1PutConfigurationRecorderCommandError = async ( ); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5116,8 +5185,7 @@ const deserializeAws_json1_1PutConformancePackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConformancePackTemplateValidationException": case "com.amazonaws.configservice#ConformancePackTemplateValidationException": @@ -5136,10 +5204,12 @@ const deserializeAws_json1_1PutConformancePackCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5168,8 +5238,7 @@ const deserializeAws_json1_1PutDeliveryChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientDeliveryPolicyException": case "com.amazonaws.configservice#InsufficientDeliveryPolicyException": @@ -5197,10 +5266,12 @@ const deserializeAws_json1_1PutDeliveryChannelCommandError = async ( throw await deserializeAws_json1_1NoSuchBucketExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5232,8 +5303,7 @@ const deserializeAws_json1_1PutEvaluationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -5246,10 +5316,12 @@ const deserializeAws_json1_1PutEvaluationsCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5281,8 +5353,7 @@ const deserializeAws_json1_1PutExternalEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -5292,10 +5363,12 @@ const deserializeAws_json1_1PutExternalEvaluationCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigRuleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5327,8 +5400,7 @@ const deserializeAws_json1_1PutOrganizationConfigRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5359,10 +5431,12 @@ const deserializeAws_json1_1PutOrganizationConfigRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5394,8 +5468,7 @@ const deserializeAws_json1_1PutOrganizationConformancePackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5429,10 +5502,12 @@ const deserializeAws_json1_1PutOrganizationConformancePackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5464,8 +5539,7 @@ const deserializeAws_json1_1PutRemediationConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5475,10 +5549,12 @@ const deserializeAws_json1_1PutRemediationConfigurationsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5510,8 +5586,7 @@ const deserializeAws_json1_1PutRemediationExceptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5521,10 +5596,12 @@ const deserializeAws_json1_1PutRemediationExceptionsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5553,8 +5630,7 @@ const deserializeAws_json1_1PutResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5570,10 +5646,12 @@ const deserializeAws_json1_1PutResourceConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5605,8 +5683,7 @@ const deserializeAws_json1_1PutRetentionConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -5619,10 +5696,12 @@ const deserializeAws_json1_1PutRetentionConfigurationCommandError = async ( ); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5654,8 +5733,7 @@ const deserializeAws_json1_1PutStoredQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceConcurrentModificationException": case "com.amazonaws.configservice#ResourceConcurrentModificationException": @@ -5668,10 +5746,12 @@ const deserializeAws_json1_1PutStoredQueryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5703,8 +5783,7 @@ const deserializeAws_json1_1SelectAggregateResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidExpressionException": case "com.amazonaws.configservice#InvalidExpressionException": @@ -5720,10 +5799,12 @@ const deserializeAws_json1_1SelectAggregateResourceConfigCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigurationAggregatorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5755,8 +5836,7 @@ const deserializeAws_json1_1SelectResourceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidExpressionException": case "com.amazonaws.configservice#InvalidExpressionException": @@ -5769,10 +5849,12 @@ const deserializeAws_json1_1SelectResourceConfigCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5804,8 +5886,7 @@ const deserializeAws_json1_1StartConfigRulesEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.configservice#InvalidParameterValueException": @@ -5821,10 +5902,12 @@ const deserializeAws_json1_1StartConfigRulesEvaluationCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5853,8 +5936,7 @@ const deserializeAws_json1_1StartConfigurationRecorderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoAvailableDeliveryChannelException": case "com.amazonaws.configservice#NoAvailableDeliveryChannelException": @@ -5864,10 +5946,12 @@ const deserializeAws_json1_1StartConfigurationRecorderCommandError = async ( throw await deserializeAws_json1_1NoSuchConfigurationRecorderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5899,8 +5983,7 @@ const deserializeAws_json1_1StartRemediationExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPermissionsException": case "com.amazonaws.configservice#InsufficientPermissionsException": @@ -5913,10 +5996,12 @@ const deserializeAws_json1_1StartRemediationExecutionCommandError = async ( throw await deserializeAws_json1_1NoSuchRemediationConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5945,18 +6030,19 @@ const deserializeAws_json1_1StopConfigurationRecorderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchConfigurationRecorderException": case "com.amazonaws.configservice#NoSuchConfigurationRecorderException": throw await deserializeAws_json1_1NoSuchConfigurationRecorderExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5985,8 +6071,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.configservice#ResourceNotFoundException": @@ -5999,10 +6084,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6031,8 +6118,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.configservice#ResourceNotFoundException": @@ -6042,10 +6128,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12448,7 +12536,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -12474,6 +12562,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-connect-contact-lens/src/protocols/Aws_restJson1.ts b/clients/client-connect-contact-lens/src/protocols/Aws_restJson1.ts index 467299d9cffd3..c6e2de6ad0c18 100644 --- a/clients/client-connect-contact-lens/src/protocols/Aws_restJson1.ts +++ b/clients/client-connect-contact-lens/src/protocols/Aws_restJson1.ts @@ -93,8 +93,7 @@ const deserializeAws_restJson1ListRealtimeContactAnalysisSegmentsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcontactlens#AccessDeniedException": @@ -113,10 +112,12 @@ const deserializeAws_restJson1ListRealtimeContactAnalysisSegmentsCommandError = throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -382,7 +383,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -408,6 +409,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-connect/src/protocols/Aws_restJson1.ts b/clients/client-connect/src/protocols/Aws_restJson1.ts index 3c04514903d72..a2ca07f3f38a8 100644 --- a/clients/client-connect/src/protocols/Aws_restJson1.ts +++ b/clients/client-connect/src/protocols/Aws_restJson1.ts @@ -6487,8 +6487,7 @@ const deserializeAws_restJson1AssociateApprovedOriginCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6513,10 +6512,12 @@ const deserializeAws_restJson1AssociateApprovedOriginCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6545,8 +6546,7 @@ const deserializeAws_restJson1AssociateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6571,10 +6571,12 @@ const deserializeAws_restJson1AssociateBotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6603,8 +6605,7 @@ const deserializeAws_restJson1AssociateDefaultVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -6623,10 +6624,12 @@ const deserializeAws_restJson1AssociateDefaultVocabularyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6659,8 +6662,7 @@ const deserializeAws_restJson1AssociateInstanceStorageConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6682,10 +6684,12 @@ const deserializeAws_restJson1AssociateInstanceStorageConfigCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6714,8 +6718,7 @@ const deserializeAws_restJson1AssociateLambdaFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6740,10 +6743,12 @@ const deserializeAws_restJson1AssociateLambdaFunctionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6772,8 +6777,7 @@ const deserializeAws_restJson1AssociateLexBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6798,10 +6802,12 @@ const deserializeAws_restJson1AssociateLexBotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6830,8 +6836,7 @@ const deserializeAws_restJson1AssociatePhoneNumberContactFlowCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -6850,10 +6855,12 @@ const deserializeAws_restJson1AssociatePhoneNumberContactFlowCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6882,8 +6889,7 @@ const deserializeAws_restJson1AssociateQueueQuickConnectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6905,10 +6911,12 @@ const deserializeAws_restJson1AssociateQueueQuickConnectsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6937,8 +6945,7 @@ const deserializeAws_restJson1AssociateRoutingProfileQueuesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -6957,10 +6964,12 @@ const deserializeAws_restJson1AssociateRoutingProfileQueuesCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6993,8 +7002,7 @@ const deserializeAws_restJson1AssociateSecurityKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -7019,10 +7027,12 @@ const deserializeAws_restJson1AssociateSecurityKeyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7059,8 +7069,7 @@ const deserializeAws_restJson1ClaimPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -7082,10 +7091,12 @@ const deserializeAws_restJson1ClaimPhoneNumberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7122,8 +7133,7 @@ const deserializeAws_restJson1CreateAgentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7148,10 +7158,12 @@ const deserializeAws_restJson1CreateAgentStatusCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7188,8 +7200,7 @@ const deserializeAws_restJson1CreateContactFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7217,10 +7228,12 @@ const deserializeAws_restJson1CreateContactFlowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7257,8 +7270,7 @@ const deserializeAws_restJson1CreateContactFlowModuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -7292,10 +7304,12 @@ const deserializeAws_restJson1CreateContactFlowModuleCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7332,8 +7346,7 @@ const deserializeAws_restJson1CreateHoursOfOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7358,10 +7371,12 @@ const deserializeAws_restJson1CreateHoursOfOperationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7398,8 +7413,7 @@ const deserializeAws_restJson1CreateInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -7418,10 +7432,12 @@ const deserializeAws_restJson1CreateInstanceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7458,8 +7474,7 @@ const deserializeAws_restJson1CreateIntegrationAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7478,10 +7493,12 @@ const deserializeAws_restJson1CreateIntegrationAssociationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7518,8 +7535,7 @@ const deserializeAws_restJson1CreateQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7544,10 +7560,12 @@ const deserializeAws_restJson1CreateQueueCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7584,8 +7602,7 @@ const deserializeAws_restJson1CreateQuickConnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7610,10 +7627,12 @@ const deserializeAws_restJson1CreateQuickConnectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7650,8 +7669,7 @@ const deserializeAws_restJson1CreateRoutingProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7676,10 +7694,12 @@ const deserializeAws_restJson1CreateRoutingProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7716,8 +7736,7 @@ const deserializeAws_restJson1CreateSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7742,10 +7761,12 @@ const deserializeAws_restJson1CreateSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7782,8 +7803,7 @@ const deserializeAws_restJson1CreateTaskTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -7805,10 +7825,12 @@ const deserializeAws_restJson1CreateTaskTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7845,8 +7867,7 @@ const deserializeAws_restJson1CreateUseCaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7865,10 +7886,12 @@ const deserializeAws_restJson1CreateUseCaseCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7905,8 +7928,7 @@ const deserializeAws_restJson1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7931,10 +7953,12 @@ const deserializeAws_restJson1CreateUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7971,8 +7995,7 @@ const deserializeAws_restJson1CreateUserHierarchyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -7997,10 +8020,12 @@ const deserializeAws_restJson1CreateUserHierarchyGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8041,8 +8066,7 @@ const deserializeAws_restJson1CreateVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8067,10 +8091,12 @@ const deserializeAws_restJson1CreateVocabularyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8099,8 +8125,7 @@ const deserializeAws_restJson1DeleteContactFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8122,10 +8147,12 @@ const deserializeAws_restJson1DeleteContactFlowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8154,8 +8181,7 @@ const deserializeAws_restJson1DeleteContactFlowModuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8177,10 +8203,12 @@ const deserializeAws_restJson1DeleteContactFlowModuleCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8209,8 +8237,7 @@ const deserializeAws_restJson1DeleteHoursOfOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8229,10 +8256,12 @@ const deserializeAws_restJson1DeleteHoursOfOperationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8261,8 +8290,7 @@ const deserializeAws_restJson1DeleteInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8275,10 +8303,12 @@ const deserializeAws_restJson1DeleteInstanceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8307,8 +8337,7 @@ const deserializeAws_restJson1DeleteIntegrationAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8324,10 +8353,12 @@ const deserializeAws_restJson1DeleteIntegrationAssociationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8356,8 +8387,7 @@ const deserializeAws_restJson1DeleteQuickConnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8376,10 +8406,12 @@ const deserializeAws_restJson1DeleteQuickConnectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8408,8 +8440,7 @@ const deserializeAws_restJson1DeleteSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8434,10 +8465,12 @@ const deserializeAws_restJson1DeleteSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8466,8 +8499,7 @@ const deserializeAws_restJson1DeleteTaskTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8486,10 +8518,12 @@ const deserializeAws_restJson1DeleteTaskTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8518,8 +8552,7 @@ const deserializeAws_restJson1DeleteUseCaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8535,10 +8568,12 @@ const deserializeAws_restJson1DeleteUseCaseCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8567,8 +8602,7 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8587,10 +8621,12 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8619,8 +8655,7 @@ const deserializeAws_restJson1DeleteUserHierarchyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8642,10 +8677,12 @@ const deserializeAws_restJson1DeleteUserHierarchyGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8686,8 +8723,7 @@ const deserializeAws_restJson1DeleteVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8709,10 +8745,12 @@ const deserializeAws_restJson1DeleteVocabularyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8745,8 +8783,7 @@ const deserializeAws_restJson1DescribeAgentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8765,10 +8802,12 @@ const deserializeAws_restJson1DescribeAgentStatusCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8801,8 +8840,7 @@ const deserializeAws_restJson1DescribeContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8821,10 +8859,12 @@ const deserializeAws_restJson1DescribeContactCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8857,8 +8897,7 @@ const deserializeAws_restJson1DescribeContactFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContactFlowNotPublishedException": case "com.amazonaws.connect#ContactFlowNotPublishedException": @@ -8880,10 +8919,12 @@ const deserializeAws_restJson1DescribeContactFlowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8916,8 +8957,7 @@ const deserializeAws_restJson1DescribeContactFlowModuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -8939,10 +8979,12 @@ const deserializeAws_restJson1DescribeContactFlowModuleCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8975,8 +9017,7 @@ const deserializeAws_restJson1DescribeHoursOfOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -8995,10 +9036,12 @@ const deserializeAws_restJson1DescribeHoursOfOperationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9031,8 +9074,7 @@ const deserializeAws_restJson1DescribeInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9045,10 +9087,12 @@ const deserializeAws_restJson1DescribeInstanceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9081,8 +9125,7 @@ const deserializeAws_restJson1DescribeInstanceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9101,10 +9144,12 @@ const deserializeAws_restJson1DescribeInstanceAttributeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9137,8 +9182,7 @@ const deserializeAws_restJson1DescribeInstanceStorageConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9157,10 +9201,12 @@ const deserializeAws_restJson1DescribeInstanceStorageConfigCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9196,8 +9242,7 @@ const deserializeAws_restJson1DescribePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -9216,10 +9261,12 @@ const deserializeAws_restJson1DescribePhoneNumberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9252,8 +9299,7 @@ const deserializeAws_restJson1DescribeQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9272,10 +9318,12 @@ const deserializeAws_restJson1DescribeQueueCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9308,8 +9356,7 @@ const deserializeAws_restJson1DescribeQuickConnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9328,10 +9375,12 @@ const deserializeAws_restJson1DescribeQuickConnectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9364,8 +9413,7 @@ const deserializeAws_restJson1DescribeRoutingProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9384,10 +9432,12 @@ const deserializeAws_restJson1DescribeRoutingProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9420,8 +9470,7 @@ const deserializeAws_restJson1DescribeSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9440,10 +9489,12 @@ const deserializeAws_restJson1DescribeSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9476,8 +9527,7 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9496,10 +9546,12 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9532,8 +9584,7 @@ const deserializeAws_restJson1DescribeUserHierarchyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9552,10 +9603,12 @@ const deserializeAws_restJson1DescribeUserHierarchyGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9588,8 +9641,7 @@ const deserializeAws_restJson1DescribeUserHierarchyStructureCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9608,10 +9660,12 @@ const deserializeAws_restJson1DescribeUserHierarchyStructureCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9644,8 +9698,7 @@ const deserializeAws_restJson1DescribeVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -9664,10 +9717,12 @@ const deserializeAws_restJson1DescribeVocabularyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9696,8 +9751,7 @@ const deserializeAws_restJson1DisassociateApprovedOriginCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9716,10 +9770,12 @@ const deserializeAws_restJson1DisassociateApprovedOriginCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9748,8 +9804,7 @@ const deserializeAws_restJson1DisassociateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9765,10 +9820,12 @@ const deserializeAws_restJson1DisassociateBotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9797,8 +9854,7 @@ const deserializeAws_restJson1DisassociateInstanceStorageConfigCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9817,10 +9873,12 @@ const deserializeAws_restJson1DisassociateInstanceStorageConfigCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9849,8 +9907,7 @@ const deserializeAws_restJson1DisassociateLambdaFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9869,10 +9926,12 @@ const deserializeAws_restJson1DisassociateLambdaFunctionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9901,8 +9960,7 @@ const deserializeAws_restJson1DisassociateLexBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -9921,10 +9979,12 @@ const deserializeAws_restJson1DisassociateLexBotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9953,8 +10013,7 @@ const deserializeAws_restJson1DisassociatePhoneNumberContactFlowCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -9973,10 +10032,12 @@ const deserializeAws_restJson1DisassociatePhoneNumberContactFlowCommandError = a throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10005,8 +10066,7 @@ const deserializeAws_restJson1DisassociateQueueQuickConnectsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10025,10 +10085,12 @@ const deserializeAws_restJson1DisassociateQueueQuickConnectsCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10057,8 +10119,7 @@ const deserializeAws_restJson1DisassociateRoutingProfileQueuesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10077,10 +10138,12 @@ const deserializeAws_restJson1DisassociateRoutingProfileQueuesCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10109,8 +10172,7 @@ const deserializeAws_restJson1DisassociateSecurityKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10129,10 +10191,12 @@ const deserializeAws_restJson1DisassociateSecurityKeyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10165,8 +10229,7 @@ const deserializeAws_restJson1GetContactAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10179,10 +10242,12 @@ const deserializeAws_restJson1GetContactAttributesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10223,8 +10288,7 @@ const deserializeAws_restJson1GetCurrentMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10243,10 +10307,12 @@ const deserializeAws_restJson1GetCurrentMetricDataCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10283,8 +10349,7 @@ const deserializeAws_restJson1GetCurrentUserDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10303,10 +10368,12 @@ const deserializeAws_restJson1GetCurrentUserDataCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10339,8 +10406,7 @@ const deserializeAws_restJson1GetFederationTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -10362,10 +10428,12 @@ const deserializeAws_restJson1GetFederationTokenCommandError = async ( throw await deserializeAws_restJson1UserNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10402,8 +10470,7 @@ const deserializeAws_restJson1GetMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10422,10 +10489,12 @@ const deserializeAws_restJson1GetMetricDataCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10506,8 +10575,7 @@ const deserializeAws_restJson1GetTaskTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10526,10 +10594,12 @@ const deserializeAws_restJson1GetTaskTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10569,8 +10639,7 @@ const deserializeAws_restJson1ListAgentStatusesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10589,10 +10658,12 @@ const deserializeAws_restJson1ListAgentStatusesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10629,8 +10700,7 @@ const deserializeAws_restJson1ListApprovedOriginsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10649,10 +10719,12 @@ const deserializeAws_restJson1ListApprovedOriginsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10689,8 +10761,7 @@ const deserializeAws_restJson1ListBotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10706,10 +10777,12 @@ const deserializeAws_restJson1ListBotsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10749,8 +10822,7 @@ const deserializeAws_restJson1ListContactFlowModulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -10772,10 +10844,12 @@ const deserializeAws_restJson1ListContactFlowModulesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10815,8 +10889,7 @@ const deserializeAws_restJson1ListContactFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10835,10 +10908,12 @@ const deserializeAws_restJson1ListContactFlowsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10875,8 +10950,7 @@ const deserializeAws_restJson1ListContactReferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -10895,10 +10969,12 @@ const deserializeAws_restJson1ListContactReferencesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10935,8 +11011,7 @@ const deserializeAws_restJson1ListDefaultVocabulariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -10952,10 +11027,12 @@ const deserializeAws_restJson1ListDefaultVocabulariesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10995,8 +11072,7 @@ const deserializeAws_restJson1ListHoursOfOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11015,10 +11091,12 @@ const deserializeAws_restJson1ListHoursOfOperationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11055,8 +11133,7 @@ const deserializeAws_restJson1ListInstanceAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11075,10 +11152,12 @@ const deserializeAws_restJson1ListInstanceAttributesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11115,8 +11194,7 @@ const deserializeAws_restJson1ListInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11126,10 +11204,12 @@ const deserializeAws_restJson1ListInstancesCommandError = async ( throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11166,8 +11246,7 @@ const deserializeAws_restJson1ListInstanceStorageConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11186,10 +11265,12 @@ const deserializeAws_restJson1ListInstanceStorageConfigsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11229,8 +11310,7 @@ const deserializeAws_restJson1ListIntegrationAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11246,10 +11326,12 @@ const deserializeAws_restJson1ListIntegrationAssociationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11286,8 +11368,7 @@ const deserializeAws_restJson1ListLambdaFunctionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11306,10 +11387,12 @@ const deserializeAws_restJson1ListLambdaFunctionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11346,8 +11429,7 @@ const deserializeAws_restJson1ListLexBotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11366,10 +11448,12 @@ const deserializeAws_restJson1ListLexBotsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11409,8 +11493,7 @@ const deserializeAws_restJson1ListPhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11429,10 +11512,12 @@ const deserializeAws_restJson1ListPhoneNumbersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11472,8 +11557,7 @@ const deserializeAws_restJson1ListPhoneNumbersV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -11492,10 +11576,12 @@ const deserializeAws_restJson1ListPhoneNumbersV2CommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11532,8 +11618,7 @@ const deserializeAws_restJson1ListPromptsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11552,10 +11637,12 @@ const deserializeAws_restJson1ListPromptsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11595,8 +11682,7 @@ const deserializeAws_restJson1ListQueueQuickConnectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11615,10 +11701,12 @@ const deserializeAws_restJson1ListQueueQuickConnectsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11655,8 +11743,7 @@ const deserializeAws_restJson1ListQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11675,10 +11762,12 @@ const deserializeAws_restJson1ListQueuesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11718,8 +11807,7 @@ const deserializeAws_restJson1ListQuickConnectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11738,10 +11826,12 @@ const deserializeAws_restJson1ListQuickConnectsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11781,8 +11871,7 @@ const deserializeAws_restJson1ListRoutingProfileQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11801,10 +11890,12 @@ const deserializeAws_restJson1ListRoutingProfileQueuesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11844,8 +11935,7 @@ const deserializeAws_restJson1ListRoutingProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11864,10 +11954,12 @@ const deserializeAws_restJson1ListRoutingProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11904,8 +11996,7 @@ const deserializeAws_restJson1ListSecurityKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11924,10 +12015,12 @@ const deserializeAws_restJson1ListSecurityKeysCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11964,8 +12057,7 @@ const deserializeAws_restJson1ListSecurityProfilePermissionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -11984,10 +12076,12 @@ const deserializeAws_restJson1ListSecurityProfilePermissionsCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12027,8 +12121,7 @@ const deserializeAws_restJson1ListSecurityProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12047,10 +12140,12 @@ const deserializeAws_restJson1ListSecurityProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12083,8 +12178,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12103,10 +12197,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12143,8 +12239,7 @@ const deserializeAws_restJson1ListTaskTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12163,10 +12258,12 @@ const deserializeAws_restJson1ListTaskTemplatesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12203,8 +12300,7 @@ const deserializeAws_restJson1ListUseCasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12220,10 +12316,12 @@ const deserializeAws_restJson1ListUseCasesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12263,8 +12361,7 @@ const deserializeAws_restJson1ListUserHierarchyGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12283,10 +12380,12 @@ const deserializeAws_restJson1ListUserHierarchyGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12323,8 +12422,7 @@ const deserializeAws_restJson1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12343,10 +12441,12 @@ const deserializeAws_restJson1ListUsersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12375,8 +12475,7 @@ const deserializeAws_restJson1PutUserStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -12398,10 +12497,12 @@ const deserializeAws_restJson1PutUserStatusCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12430,8 +12531,7 @@ const deserializeAws_restJson1ReleasePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -12456,10 +12556,12 @@ const deserializeAws_restJson1ReleasePhoneNumberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12488,8 +12590,7 @@ const deserializeAws_restJson1ResumeContactRecordingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12502,10 +12603,12 @@ const deserializeAws_restJson1ResumeContactRecordingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12542,8 +12645,7 @@ const deserializeAws_restJson1SearchAvailablePhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -12559,10 +12661,12 @@ const deserializeAws_restJson1SearchAvailablePhoneNumbersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12603,8 +12707,7 @@ const deserializeAws_restJson1SearchUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12623,10 +12726,12 @@ const deserializeAws_restJson1SearchUsersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12663,8 +12768,7 @@ const deserializeAws_restJson1SearchVocabulariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -12680,10 +12784,12 @@ const deserializeAws_restJson1SearchVocabulariesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12724,8 +12830,7 @@ const deserializeAws_restJson1StartChatContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12744,10 +12849,12 @@ const deserializeAws_restJson1StartChatContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12776,8 +12883,7 @@ const deserializeAws_restJson1StartContactRecordingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12793,10 +12899,12 @@ const deserializeAws_restJson1StartContactRecordingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12829,8 +12937,7 @@ const deserializeAws_restJson1StartContactStreamingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12849,10 +12956,12 @@ const deserializeAws_restJson1StartContactStreamingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12885,8 +12994,7 @@ const deserializeAws_restJson1StartOutboundVoiceContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DestinationNotAllowedException": case "com.amazonaws.connect#DestinationNotAllowedException": @@ -12911,10 +13019,12 @@ const deserializeAws_restJson1StartOutboundVoiceContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12947,8 +13057,7 @@ const deserializeAws_restJson1StartTaskContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -12970,10 +13079,12 @@ const deserializeAws_restJson1StartTaskContactCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13002,8 +13113,7 @@ const deserializeAws_restJson1StopContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContactNotFoundException": case "com.amazonaws.connect#ContactNotFoundException": @@ -13022,10 +13132,12 @@ const deserializeAws_restJson1StopContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13054,8 +13166,7 @@ const deserializeAws_restJson1StopContactRecordingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13068,10 +13179,12 @@ const deserializeAws_restJson1StopContactRecordingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13100,8 +13213,7 @@ const deserializeAws_restJson1StopContactStreamingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13117,10 +13229,12 @@ const deserializeAws_restJson1StopContactStreamingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13149,8 +13263,7 @@ const deserializeAws_restJson1SuspendContactRecordingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13163,10 +13276,12 @@ const deserializeAws_restJson1SuspendContactRecordingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13195,8 +13310,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13215,10 +13329,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13255,8 +13371,7 @@ const deserializeAws_restJson1TransferContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -13281,10 +13396,12 @@ const deserializeAws_restJson1TransferContactCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13313,8 +13430,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13333,10 +13449,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13365,8 +13483,7 @@ const deserializeAws_restJson1UpdateAgentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -13391,10 +13508,12 @@ const deserializeAws_restJson1UpdateAgentStatusCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13423,8 +13542,7 @@ const deserializeAws_restJson1UpdateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13443,10 +13561,12 @@ const deserializeAws_restJson1UpdateContactCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13475,8 +13595,7 @@ const deserializeAws_restJson1UpdateContactAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13492,10 +13611,12 @@ const deserializeAws_restJson1UpdateContactAttributesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13524,8 +13645,7 @@ const deserializeAws_restJson1UpdateContactFlowContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13547,10 +13667,12 @@ const deserializeAws_restJson1UpdateContactFlowContentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13579,8 +13701,7 @@ const deserializeAws_restJson1UpdateContactFlowMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -13602,10 +13723,12 @@ const deserializeAws_restJson1UpdateContactFlowMetadataCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13634,8 +13757,7 @@ const deserializeAws_restJson1UpdateContactFlowModuleContentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -13657,10 +13779,12 @@ const deserializeAws_restJson1UpdateContactFlowModuleContentCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13689,8 +13813,7 @@ const deserializeAws_restJson1UpdateContactFlowModuleMetadataCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -13715,10 +13838,12 @@ const deserializeAws_restJson1UpdateContactFlowModuleMetadataCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13747,8 +13872,7 @@ const deserializeAws_restJson1UpdateContactFlowNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -13770,10 +13894,12 @@ const deserializeAws_restJson1UpdateContactFlowNameCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13802,8 +13928,7 @@ const deserializeAws_restJson1UpdateContactScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13825,10 +13950,12 @@ const deserializeAws_restJson1UpdateContactScheduleCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13857,8 +13984,7 @@ const deserializeAws_restJson1UpdateHoursOfOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -13880,10 +14006,12 @@ const deserializeAws_restJson1UpdateHoursOfOperationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13912,8 +14040,7 @@ const deserializeAws_restJson1UpdateInstanceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13932,10 +14059,12 @@ const deserializeAws_restJson1UpdateInstanceAttributeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13964,8 +14093,7 @@ const deserializeAws_restJson1UpdateInstanceStorageConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -13984,10 +14112,12 @@ const deserializeAws_restJson1UpdateInstanceStorageConfigCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14024,8 +14154,7 @@ const deserializeAws_restJson1UpdatePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connect#AccessDeniedException": @@ -14050,10 +14179,12 @@ const deserializeAws_restJson1UpdatePhoneNumberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14082,8 +14213,7 @@ const deserializeAws_restJson1UpdateQueueHoursOfOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14102,10 +14232,12 @@ const deserializeAws_restJson1UpdateQueueHoursOfOperationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14134,8 +14266,7 @@ const deserializeAws_restJson1UpdateQueueMaxContactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14154,10 +14285,12 @@ const deserializeAws_restJson1UpdateQueueMaxContactsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14186,8 +14319,7 @@ const deserializeAws_restJson1UpdateQueueNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -14209,10 +14341,12 @@ const deserializeAws_restJson1UpdateQueueNameCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14241,8 +14375,7 @@ const deserializeAws_restJson1UpdateQueueOutboundCallerConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14261,10 +14394,12 @@ const deserializeAws_restJson1UpdateQueueOutboundCallerConfigCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14293,8 +14428,7 @@ const deserializeAws_restJson1UpdateQueueStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14313,10 +14447,12 @@ const deserializeAws_restJson1UpdateQueueStatusCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14345,8 +14481,7 @@ const deserializeAws_restJson1UpdateQuickConnectConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14365,10 +14500,12 @@ const deserializeAws_restJson1UpdateQuickConnectConfigCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14397,8 +14534,7 @@ const deserializeAws_restJson1UpdateQuickConnectNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14417,10 +14553,12 @@ const deserializeAws_restJson1UpdateQuickConnectNameCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14449,8 +14587,7 @@ const deserializeAws_restJson1UpdateRoutingProfileConcurrencyCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14469,10 +14606,12 @@ const deserializeAws_restJson1UpdateRoutingProfileConcurrencyCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14501,8 +14640,7 @@ const deserializeAws_restJson1UpdateRoutingProfileDefaultOutboundQueueCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14521,10 +14659,12 @@ const deserializeAws_restJson1UpdateRoutingProfileDefaultOutboundQueueCommandErr throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14553,8 +14693,7 @@ const deserializeAws_restJson1UpdateRoutingProfileNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -14576,10 +14715,12 @@ const deserializeAws_restJson1UpdateRoutingProfileNameCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14608,8 +14749,7 @@ const deserializeAws_restJson1UpdateRoutingProfileQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14628,10 +14768,12 @@ const deserializeAws_restJson1UpdateRoutingProfileQueuesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14660,8 +14802,7 @@ const deserializeAws_restJson1UpdateSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14680,10 +14821,12 @@ const deserializeAws_restJson1UpdateSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14760,8 +14903,7 @@ const deserializeAws_restJson1UpdateTaskTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14783,10 +14925,12 @@ const deserializeAws_restJson1UpdateTaskTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14815,8 +14959,7 @@ const deserializeAws_restJson1UpdateUserHierarchyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14835,10 +14978,12 @@ const deserializeAws_restJson1UpdateUserHierarchyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14867,8 +15012,7 @@ const deserializeAws_restJson1UpdateUserHierarchyGroupNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.connect#DuplicateResourceException": @@ -14890,10 +15034,12 @@ const deserializeAws_restJson1UpdateUserHierarchyGroupNameCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14922,8 +15068,7 @@ const deserializeAws_restJson1UpdateUserHierarchyStructureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14945,10 +15090,12 @@ const deserializeAws_restJson1UpdateUserHierarchyStructureCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14977,8 +15124,7 @@ const deserializeAws_restJson1UpdateUserIdentityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -14997,10 +15143,12 @@ const deserializeAws_restJson1UpdateUserIdentityInfoCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15029,8 +15177,7 @@ const deserializeAws_restJson1UpdateUserPhoneConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -15049,10 +15196,12 @@ const deserializeAws_restJson1UpdateUserPhoneConfigCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15081,8 +15230,7 @@ const deserializeAws_restJson1UpdateUserRoutingProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -15101,10 +15249,12 @@ const deserializeAws_restJson1UpdateUserRoutingProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15133,8 +15283,7 @@ const deserializeAws_restJson1UpdateUserSecurityProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.connect#InternalServiceException": @@ -15153,10 +15302,12 @@ const deserializeAws_restJson1UpdateUserSecurityProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18305,7 +18456,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -18331,6 +18482,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-connectcampaigns/src/protocols/Aws_restJson1.ts b/clients/client-connectcampaigns/src/protocols/Aws_restJson1.ts index 3899573439d36..837af788251e5 100644 --- a/clients/client-connectcampaigns/src/protocols/Aws_restJson1.ts +++ b/clients/client-connectcampaigns/src/protocols/Aws_restJson1.ts @@ -815,8 +815,7 @@ const deserializeAws_restJson1CreateCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -841,10 +840,12 @@ const deserializeAws_restJson1CreateCampaignCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -873,8 +874,7 @@ const deserializeAws_restJson1DeleteCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -890,10 +890,12 @@ const deserializeAws_restJson1DeleteCampaignCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -922,8 +924,7 @@ const deserializeAws_restJson1DeleteConnectInstanceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -945,10 +946,12 @@ const deserializeAws_restJson1DeleteConnectInstanceConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -977,8 +980,7 @@ const deserializeAws_restJson1DeleteInstanceOnboardingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -997,10 +999,12 @@ const deserializeAws_restJson1DeleteInstanceOnboardingJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1033,8 +1037,7 @@ const deserializeAws_restJson1DescribeCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1050,10 +1053,12 @@ const deserializeAws_restJson1DescribeCampaignCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1086,8 +1091,7 @@ const deserializeAws_restJson1GetCampaignStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1103,10 +1107,12 @@ const deserializeAws_restJson1GetCampaignStateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1146,8 +1152,7 @@ const deserializeAws_restJson1GetCampaignStateBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1163,10 +1168,12 @@ const deserializeAws_restJson1GetCampaignStateBatchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1199,8 +1206,7 @@ const deserializeAws_restJson1GetConnectInstanceConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1216,10 +1222,12 @@ const deserializeAws_restJson1GetConnectInstanceConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1255,8 +1263,7 @@ const deserializeAws_restJson1GetInstanceOnboardingJobStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1272,10 +1279,12 @@ const deserializeAws_restJson1GetInstanceOnboardingJobStatusCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1312,8 +1321,7 @@ const deserializeAws_restJson1ListCampaignsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1326,10 +1334,12 @@ const deserializeAws_restJson1ListCampaignsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1362,8 +1372,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1382,10 +1391,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1414,8 +1425,7 @@ const deserializeAws_restJson1PauseCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1437,10 +1447,12 @@ const deserializeAws_restJson1PauseCampaignCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1477,8 +1489,7 @@ const deserializeAws_restJson1PutDialRequestBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1503,10 +1514,12 @@ const deserializeAws_restJson1PutDialRequestBatchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1535,8 +1548,7 @@ const deserializeAws_restJson1ResumeCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1558,10 +1570,12 @@ const deserializeAws_restJson1ResumeCampaignCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1590,8 +1604,7 @@ const deserializeAws_restJson1StartCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1613,10 +1626,12 @@ const deserializeAws_restJson1StartCampaignCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1652,8 +1667,7 @@ const deserializeAws_restJson1StartInstanceOnboardingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1675,10 +1689,12 @@ const deserializeAws_restJson1StartInstanceOnboardingJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1707,8 +1723,7 @@ const deserializeAws_restJson1StopCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1730,10 +1745,12 @@ const deserializeAws_restJson1StopCampaignCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1762,8 +1779,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1782,10 +1798,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1832,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1834,10 +1851,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1866,8 +1885,7 @@ const deserializeAws_restJson1UpdateCampaignDialerConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1886,10 +1904,12 @@ const deserializeAws_restJson1UpdateCampaignDialerConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1918,8 +1938,7 @@ const deserializeAws_restJson1UpdateCampaignNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1938,10 +1957,12 @@ const deserializeAws_restJson1UpdateCampaignNameCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1970,8 +1991,7 @@ const deserializeAws_restJson1UpdateCampaignOutboundCallConfigCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectcampaigns#AccessDeniedException": @@ -1993,10 +2013,12 @@ const deserializeAws_restJson1UpdateCampaignOutboundCallConfigCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2580,7 +2602,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2606,6 +2628,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-connectparticipant/src/protocols/Aws_restJson1.ts b/clients/client-connectparticipant/src/protocols/Aws_restJson1.ts index f9e652c7e9370..5fd8dc4f8c61c 100644 --- a/clients/client-connectparticipant/src/protocols/Aws_restJson1.ts +++ b/clients/client-connectparticipant/src/protocols/Aws_restJson1.ts @@ -303,8 +303,7 @@ const deserializeAws_restJson1CompleteAttachmentUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -326,10 +325,12 @@ const deserializeAws_restJson1CompleteAttachmentUploadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -366,8 +367,7 @@ const deserializeAws_restJson1CreateParticipantConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -383,10 +383,12 @@ const deserializeAws_restJson1CreateParticipantConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -415,8 +417,7 @@ const deserializeAws_restJson1DisconnectParticipantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -432,10 +433,12 @@ const deserializeAws_restJson1DisconnectParticipantCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -472,8 +475,7 @@ const deserializeAws_restJson1GetAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -489,10 +491,12 @@ const deserializeAws_restJson1GetAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -533,8 +537,7 @@ const deserializeAws_restJson1GetTranscriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -550,10 +553,12 @@ const deserializeAws_restJson1GetTranscriptCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -590,8 +595,7 @@ const deserializeAws_restJson1SendEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -607,10 +611,12 @@ const deserializeAws_restJson1SendEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -647,8 +653,7 @@ const deserializeAws_restJson1SendMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -664,10 +669,12 @@ const deserializeAws_restJson1SendMessageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -704,8 +711,7 @@ const deserializeAws_restJson1StartAttachmentUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.connectparticipant#AccessDeniedException": @@ -724,10 +730,12 @@ const deserializeAws_restJson1StartAttachmentUploadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -986,7 +994,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1012,6 +1020,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cost-and-usage-report-service/src/protocols/Aws_json1_1.ts b/clients/client-cost-and-usage-report-service/src/protocols/Aws_json1_1.ts index 270b0434c3737..c46b69fef190d 100644 --- a/clients/client-cost-and-usage-report-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-cost-and-usage-report-service/src/protocols/Aws_json1_1.ts @@ -125,8 +125,7 @@ const deserializeAws_json1_1DeleteReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.costandusagereportservice#InternalErrorException": @@ -136,10 +135,12 @@ const deserializeAws_json1_1DeleteReportDefinitionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -171,18 +172,19 @@ const deserializeAws_json1_1DescribeReportDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.costandusagereportservice#InternalErrorException": throw await deserializeAws_json1_1InternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -214,8 +216,7 @@ const deserializeAws_json1_1ModifyReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.costandusagereportservice#InternalErrorException": @@ -225,10 +226,12 @@ const deserializeAws_json1_1ModifyReportDefinitionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -260,8 +263,7 @@ const deserializeAws_json1_1PutReportDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateReportNameException": case "com.amazonaws.costandusagereportservice#DuplicateReportNameException": @@ -277,10 +279,12 @@ const deserializeAws_json1_1PutReportDefinitionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -616,7 +620,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -642,6 +646,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts b/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts index e17e480fedf7c..cb2b693a3b23f 100644 --- a/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts +++ b/clients/client-cost-explorer/src/protocols/Aws_json1_1.ts @@ -776,18 +776,19 @@ const deserializeAws_json1_1CreateAnomalyMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -819,8 +820,7 @@ const deserializeAws_json1_1CreateAnomalySubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -830,10 +830,12 @@ const deserializeAws_json1_1CreateAnomalySubscriptionCommandError = async ( throw await deserializeAws_json1_1UnknownMonitorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -865,8 +867,7 @@ const deserializeAws_json1_1CreateCostCategoryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -876,10 +877,12 @@ const deserializeAws_json1_1CreateCostCategoryDefinitionCommandError = async ( throw await deserializeAws_json1_1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +914,7 @@ const deserializeAws_json1_1DeleteAnomalyMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -922,10 +924,12 @@ const deserializeAws_json1_1DeleteAnomalyMonitorCommandError = async ( throw await deserializeAws_json1_1UnknownMonitorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -957,8 +961,7 @@ const deserializeAws_json1_1DeleteAnomalySubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -968,10 +971,12 @@ const deserializeAws_json1_1DeleteAnomalySubscriptionCommandError = async ( throw await deserializeAws_json1_1UnknownSubscriptionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1003,8 +1008,7 @@ const deserializeAws_json1_1DeleteCostCategoryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -1014,10 +1018,12 @@ const deserializeAws_json1_1DeleteCostCategoryDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1049,8 +1055,7 @@ const deserializeAws_json1_1DescribeCostCategoryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -1060,10 +1065,12 @@ const deserializeAws_json1_1DescribeCostCategoryDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1095,8 +1102,7 @@ const deserializeAws_json1_1GetAnomaliesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -1106,10 +1112,12 @@ const deserializeAws_json1_1GetAnomaliesCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1141,8 +1149,7 @@ const deserializeAws_json1_1GetAnomalyMonitorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -1155,10 +1162,12 @@ const deserializeAws_json1_1GetAnomalyMonitorsCommandError = async ( throw await deserializeAws_json1_1UnknownMonitorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1190,8 +1199,7 @@ const deserializeAws_json1_1GetAnomalySubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -1204,10 +1212,12 @@ const deserializeAws_json1_1GetAnomalySubscriptionsCommandError = async ( throw await deserializeAws_json1_1UnknownSubscriptionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1239,8 +1249,7 @@ const deserializeAws_json1_1GetCostAndUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BillExpirationException": case "com.amazonaws.costexplorer#BillExpirationException": @@ -1259,10 +1268,12 @@ const deserializeAws_json1_1GetCostAndUsageCommandError = async ( throw await deserializeAws_json1_1RequestChangedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1294,8 +1305,7 @@ const deserializeAws_json1_1GetCostAndUsageWithResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BillExpirationException": case "com.amazonaws.costexplorer#BillExpirationException": @@ -1314,10 +1324,12 @@ const deserializeAws_json1_1GetCostAndUsageWithResourcesCommandError = async ( throw await deserializeAws_json1_1RequestChangedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1361,7 @@ const deserializeAws_json1_1GetCostCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BillExpirationException": case "com.amazonaws.costexplorer#BillExpirationException": @@ -1369,10 +1380,12 @@ const deserializeAws_json1_1GetCostCategoriesCommandError = async ( throw await deserializeAws_json1_1RequestChangedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1404,8 +1417,7 @@ const deserializeAws_json1_1GetCostForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1415,10 +1427,12 @@ const deserializeAws_json1_1GetCostForecastCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1450,8 +1464,7 @@ const deserializeAws_json1_1GetDimensionValuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BillExpirationException": case "com.amazonaws.costexplorer#BillExpirationException": @@ -1470,10 +1483,12 @@ const deserializeAws_json1_1GetDimensionValuesCommandError = async ( throw await deserializeAws_json1_1RequestChangedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1505,8 +1520,7 @@ const deserializeAws_json1_1GetReservationCoverageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1519,10 +1533,12 @@ const deserializeAws_json1_1GetReservationCoverageCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1554,8 +1570,7 @@ const deserializeAws_json1_1GetReservationPurchaseRecommendationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1568,10 +1583,12 @@ const deserializeAws_json1_1GetReservationPurchaseRecommendationCommandError = a throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1620,7 @@ const deserializeAws_json1_1GetReservationUtilizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1617,10 +1633,12 @@ const deserializeAws_json1_1GetReservationUtilizationCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1652,8 +1670,7 @@ const deserializeAws_json1_1GetRightsizingRecommendationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -1663,10 +1680,12 @@ const deserializeAws_json1_1GetRightsizingRecommendationCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1698,8 +1717,7 @@ const deserializeAws_json1_1GetSavingsPlansCoverageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1712,10 +1730,12 @@ const deserializeAws_json1_1GetSavingsPlansCoverageCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1747,8 +1767,7 @@ const deserializeAws_json1_1GetSavingsPlansPurchaseRecommendationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -1758,10 +1777,12 @@ const deserializeAws_json1_1GetSavingsPlansPurchaseRecommendationCommandError = throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1793,8 +1814,7 @@ const deserializeAws_json1_1GetSavingsPlansUtilizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1804,10 +1824,12 @@ const deserializeAws_json1_1GetSavingsPlansUtilizationCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1839,8 +1861,7 @@ const deserializeAws_json1_1GetSavingsPlansUtilizationDetailsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1853,10 +1874,12 @@ const deserializeAws_json1_1GetSavingsPlansUtilizationDetailsCommandError = asyn throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1888,8 +1911,7 @@ const deserializeAws_json1_1GetTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BillExpirationException": case "com.amazonaws.costexplorer#BillExpirationException": @@ -1908,10 +1930,12 @@ const deserializeAws_json1_1GetTagsCommandError = async ( throw await deserializeAws_json1_1RequestChangedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1967,7 @@ const deserializeAws_json1_1GetUsageForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DataUnavailableException": case "com.amazonaws.costexplorer#DataUnavailableException": @@ -1957,10 +1980,12 @@ const deserializeAws_json1_1GetUsageForecastCommandError = async ( throw await deserializeAws_json1_1UnresolvableUsageUnitExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1992,8 +2017,7 @@ const deserializeAws_json1_1ListCostAllocationTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.costexplorer#InvalidNextTokenException": @@ -2003,10 +2027,12 @@ const deserializeAws_json1_1ListCostAllocationTagsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2038,18 +2064,19 @@ const deserializeAws_json1_1ListCostCategoryDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2081,8 +2108,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2092,10 +2118,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2127,18 +2155,19 @@ const deserializeAws_json1_1ProvideAnomalyFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2170,8 +2199,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2184,10 +2212,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2219,8 +2249,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2230,10 +2259,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2265,8 +2296,7 @@ const deserializeAws_json1_1UpdateAnomalyMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2276,10 +2306,12 @@ const deserializeAws_json1_1UpdateAnomalyMonitorCommandError = async ( throw await deserializeAws_json1_1UnknownMonitorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2311,8 +2343,7 @@ const deserializeAws_json1_1UpdateAnomalySubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2325,10 +2356,12 @@ const deserializeAws_json1_1UpdateAnomalySubscriptionCommandError = async ( throw await deserializeAws_json1_1UnknownSubscriptionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2360,18 +2393,19 @@ const deserializeAws_json1_1UpdateCostAllocationTagsStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2403,8 +2437,7 @@ const deserializeAws_json1_1UpdateCostCategoryDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.costexplorer#LimitExceededException": @@ -2417,10 +2450,12 @@ const deserializeAws_json1_1UpdateCostCategoryDefinitionCommandError = async ( throw await deserializeAws_json1_1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5855,7 +5890,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5881,6 +5916,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-customer-profiles/src/protocols/Aws_restJson1.ts b/clients/client-customer-profiles/src/protocols/Aws_restJson1.ts index 695eb9d2bc836..1709c768d399b 100644 --- a/clients/client-customer-profiles/src/protocols/Aws_restJson1.ts +++ b/clients/client-customer-profiles/src/protocols/Aws_restJson1.ts @@ -1656,8 +1656,7 @@ const deserializeAws_restJson1AddProfileKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1676,10 +1675,12 @@ const deserializeAws_restJson1AddProfileKeyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1740,8 +1741,7 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1760,10 +1760,12 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1800,8 +1802,7 @@ const deserializeAws_restJson1CreateIntegrationWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1820,10 +1821,12 @@ const deserializeAws_restJson1CreateIntegrationWorkflowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1856,8 +1859,7 @@ const deserializeAws_restJson1CreateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1876,10 +1878,12 @@ const deserializeAws_restJson1CreateProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1912,8 +1916,7 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1932,10 +1935,12 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1968,8 +1973,7 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -1988,10 +1992,12 @@ const deserializeAws_restJson1DeleteIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2024,8 +2030,7 @@ const deserializeAws_restJson1DeleteProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2044,10 +2049,12 @@ const deserializeAws_restJson1DeleteProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2080,8 +2087,7 @@ const deserializeAws_restJson1DeleteProfileKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2100,10 +2106,12 @@ const deserializeAws_restJson1DeleteProfileKeyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2136,8 +2144,7 @@ const deserializeAws_restJson1DeleteProfileObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2156,10 +2163,12 @@ const deserializeAws_restJson1DeleteProfileObjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2192,8 +2201,7 @@ const deserializeAws_restJson1DeleteProfileObjectTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2212,10 +2220,12 @@ const deserializeAws_restJson1DeleteProfileObjectTypeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2244,8 +2254,7 @@ const deserializeAws_restJson1DeleteWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2264,10 +2273,12 @@ const deserializeAws_restJson1DeleteWorkflowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2312,8 +2323,7 @@ const deserializeAws_restJson1GetAutoMergingPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2332,10 +2342,12 @@ const deserializeAws_restJson1GetAutoMergingPreviewCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2400,8 +2412,7 @@ const deserializeAws_restJson1GetDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2420,10 +2431,12 @@ const deserializeAws_restJson1GetDomainCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2496,8 +2509,7 @@ const deserializeAws_restJson1GetIdentityResolutionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2516,10 +2528,12 @@ const deserializeAws_restJson1GetIdentityResolutionJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2580,8 +2594,7 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2600,10 +2613,12 @@ const deserializeAws_restJson1GetIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2648,8 +2663,7 @@ const deserializeAws_restJson1GetMatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2668,10 +2682,12 @@ const deserializeAws_restJson1GetMatchesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2748,8 +2764,7 @@ const deserializeAws_restJson1GetProfileObjectTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2768,10 +2783,12 @@ const deserializeAws_restJson1GetProfileObjectTypeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2828,8 +2845,7 @@ const deserializeAws_restJson1GetProfileObjectTypeTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2848,10 +2864,12 @@ const deserializeAws_restJson1GetProfileObjectTypeTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2912,8 +2930,7 @@ const deserializeAws_restJson1GetWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -2932,10 +2949,12 @@ const deserializeAws_restJson1GetWorkflowCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2980,8 +2999,7 @@ const deserializeAws_restJson1GetWorkflowStepsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3000,10 +3018,12 @@ const deserializeAws_restJson1GetWorkflowStepsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3040,8 +3060,7 @@ const deserializeAws_restJson1ListAccountIntegrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3060,10 +3079,12 @@ const deserializeAws_restJson1ListAccountIntegrationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3100,8 +3121,7 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3120,10 +3140,12 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3163,8 +3185,7 @@ const deserializeAws_restJson1ListIdentityResolutionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3183,10 +3204,12 @@ const deserializeAws_restJson1ListIdentityResolutionJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3223,8 +3246,7 @@ const deserializeAws_restJson1ListIntegrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3243,10 +3265,12 @@ const deserializeAws_restJson1ListIntegrationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3283,8 +3307,7 @@ const deserializeAws_restJson1ListProfileObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3303,10 +3326,12 @@ const deserializeAws_restJson1ListProfileObjectsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3343,8 +3368,7 @@ const deserializeAws_restJson1ListProfileObjectTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3363,10 +3387,12 @@ const deserializeAws_restJson1ListProfileObjectTypesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3403,8 +3429,7 @@ const deserializeAws_restJson1ListProfileObjectTypeTemplatesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3423,10 +3448,12 @@ const deserializeAws_restJson1ListProfileObjectTypeTemplatesCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3459,8 +3486,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.customerprofiles#BadRequestException": @@ -3473,10 +3499,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3513,8 +3541,7 @@ const deserializeAws_restJson1ListWorkflowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3533,10 +3560,12 @@ const deserializeAws_restJson1ListWorkflowsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3569,8 +3598,7 @@ const deserializeAws_restJson1MergeProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.customerprofiles#BadRequestException": @@ -3586,10 +3614,12 @@ const deserializeAws_restJson1MergeProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3650,8 +3680,7 @@ const deserializeAws_restJson1PutIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3670,10 +3699,12 @@ const deserializeAws_restJson1PutIntegrationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3706,8 +3737,7 @@ const deserializeAws_restJson1PutProfileObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3726,10 +3756,12 @@ const deserializeAws_restJson1PutProfileObjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3806,8 +3838,7 @@ const deserializeAws_restJson1PutProfileObjectTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3826,10 +3857,12 @@ const deserializeAws_restJson1PutProfileObjectTypeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3866,8 +3899,7 @@ const deserializeAws_restJson1SearchProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -3886,10 +3918,12 @@ const deserializeAws_restJson1SearchProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3918,8 +3952,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.customerprofiles#BadRequestException": @@ -3932,10 +3965,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3964,8 +3999,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.customerprofiles#BadRequestException": @@ -3978,10 +4012,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4042,8 +4078,7 @@ const deserializeAws_restJson1UpdateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -4062,10 +4097,12 @@ const deserializeAws_restJson1UpdateDomainCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4098,8 +4135,7 @@ const deserializeAws_restJson1UpdateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.customerprofiles#AccessDeniedException": @@ -4118,10 +4154,12 @@ const deserializeAws_restJson1UpdateProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5499,7 +5537,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5525,6 +5563,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-data-pipeline/src/protocols/Aws_json1_1.ts b/clients/client-data-pipeline/src/protocols/Aws_json1_1.ts index 6b04ce9364e25..80509e7daedd8 100644 --- a/clients/client-data-pipeline/src/protocols/Aws_json1_1.ts +++ b/clients/client-data-pipeline/src/protocols/Aws_json1_1.ts @@ -376,8 +376,7 @@ const deserializeAws_json1_1ActivatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -393,10 +392,12 @@ const deserializeAws_json1_1ActivatePipelineCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -428,8 +429,7 @@ const deserializeAws_json1_1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -445,10 +445,12 @@ const deserializeAws_json1_1AddTagsCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -480,8 +482,7 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -491,10 +492,12 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -526,8 +529,7 @@ const deserializeAws_json1_1DeactivatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -543,10 +545,12 @@ const deserializeAws_json1_1DeactivatePipelineCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -575,8 +579,7 @@ const deserializeAws_json1_1DeletePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -589,10 +592,12 @@ const deserializeAws_json1_1DeletePipelineCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -624,8 +629,7 @@ const deserializeAws_json1_1DescribeObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -641,10 +645,12 @@ const deserializeAws_json1_1DescribeObjectsCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -676,8 +682,7 @@ const deserializeAws_json1_1DescribePipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -693,10 +698,12 @@ const deserializeAws_json1_1DescribePipelinesCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -728,8 +735,7 @@ const deserializeAws_json1_1EvaluateExpressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -748,10 +754,12 @@ const deserializeAws_json1_1EvaluateExpressionCommandError = async ( throw await deserializeAws_json1_1TaskNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -783,8 +791,7 @@ const deserializeAws_json1_1GetPipelineDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -800,10 +807,12 @@ const deserializeAws_json1_1GetPipelineDefinitionCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -835,8 +844,7 @@ const deserializeAws_json1_1ListPipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -846,10 +854,12 @@ const deserializeAws_json1_1ListPipelinesCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -881,8 +891,7 @@ const deserializeAws_json1_1PollForTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -895,10 +904,12 @@ const deserializeAws_json1_1PollForTaskCommandError = async ( throw await deserializeAws_json1_1TaskNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -930,8 +941,7 @@ const deserializeAws_json1_1PutPipelineDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -947,10 +957,12 @@ const deserializeAws_json1_1PutPipelineDefinitionCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -982,8 +994,7 @@ const deserializeAws_json1_1QueryObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -999,10 +1010,12 @@ const deserializeAws_json1_1QueryObjectsCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1034,8 +1047,7 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1051,10 +1063,12 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1086,8 +1100,7 @@ const deserializeAws_json1_1ReportTaskProgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1106,10 +1119,12 @@ const deserializeAws_json1_1ReportTaskProgressCommandError = async ( throw await deserializeAws_json1_1TaskNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1141,8 +1156,7 @@ const deserializeAws_json1_1ReportTaskRunnerHeartbeatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1152,10 +1166,12 @@ const deserializeAws_json1_1ReportTaskRunnerHeartbeatCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1184,8 +1200,7 @@ const deserializeAws_json1_1SetStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1201,10 +1216,12 @@ const deserializeAws_json1_1SetStatusCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1236,8 +1253,7 @@ const deserializeAws_json1_1SetTaskStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1256,10 +1272,12 @@ const deserializeAws_json1_1SetTaskStatusCommandError = async ( throw await deserializeAws_json1_1TaskNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1291,8 +1309,7 @@ const deserializeAws_json1_1ValidatePipelineDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.datapipeline#InternalServiceError": @@ -1308,10 +1325,12 @@ const deserializeAws_json1_1ValidatePipelineDefinitionCommandError = async ( throw await deserializeAws_json1_1PipelineNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,7 +2292,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2299,6 +2318,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-database-migration-service/src/protocols/Aws_json1_1.ts b/clients/client-database-migration-service/src/protocols/Aws_json1_1.ts index 9a56dd060ba30..951b9cca7f53f 100644 --- a/clients/client-database-migration-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-database-migration-service/src/protocols/Aws_json1_1.ts @@ -1307,18 +1307,19 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1350,18 +1351,19 @@ const deserializeAws_json1_1ApplyPendingMaintenanceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1393,8 +1395,7 @@ const deserializeAws_json1_1CancelReplicationTaskAssessmentRunCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1407,10 +1408,12 @@ const deserializeAws_json1_1CancelReplicationTaskAssessmentRunCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1442,8 +1445,7 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1468,10 +1470,12 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( throw await deserializeAws_json1_1S3AccessDeniedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1503,8 +1507,7 @@ const deserializeAws_json1_1CreateEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "KMSAccessDeniedFault": case "com.amazonaws.databasemigrationservice#KMSAccessDeniedFault": @@ -1538,10 +1541,12 @@ const deserializeAws_json1_1CreateEventSubscriptionCommandError = async ( throw await deserializeAws_json1_1SNSNoAuthorizationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1573,8 +1578,7 @@ const deserializeAws_json1_1CreateFleetAdvisorCollectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1593,10 +1597,12 @@ const deserializeAws_json1_1CreateFleetAdvisorCollectorCommandError = async ( throw await deserializeAws_json1_1S3ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1628,8 +1634,7 @@ const deserializeAws_json1_1CreateReplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1663,10 +1668,12 @@ const deserializeAws_json1_1CreateReplicationInstanceCommandError = async ( throw await deserializeAws_json1_1StorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1698,8 +1705,7 @@ const deserializeAws_json1_1CreateReplicationSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1721,10 +1727,12 @@ const deserializeAws_json1_1CreateReplicationSubnetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1756,8 +1764,7 @@ const deserializeAws_json1_1CreateReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1779,10 +1786,12 @@ const deserializeAws_json1_1CreateReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1823,7 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -1825,10 +1833,12 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1860,8 +1870,7 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -1874,10 +1883,12 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1909,8 +1920,7 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -1920,10 +1930,12 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1955,8 +1967,7 @@ const deserializeAws_json1_1DeleteEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -1966,10 +1977,12 @@ const deserializeAws_json1_1DeleteEventSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1998,8 +2011,7 @@ const deserializeAws_json1_1DeleteFleetAdvisorCollectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CollectorNotFoundFault": case "com.amazonaws.databasemigrationservice#CollectorNotFoundFault": @@ -2009,10 +2021,12 @@ const deserializeAws_json1_1DeleteFleetAdvisorCollectorCommandError = async ( throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,8 +2058,7 @@ const deserializeAws_json1_1DeleteFleetAdvisorDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOperationFault": case "com.amazonaws.databasemigrationservice#InvalidOperationFault": @@ -2055,10 +2068,12 @@ const deserializeAws_json1_1DeleteFleetAdvisorDatabasesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2090,8 +2105,7 @@ const deserializeAws_json1_1DeleteReplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -2101,10 +2115,12 @@ const deserializeAws_json1_1DeleteReplicationInstanceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2136,8 +2152,7 @@ const deserializeAws_json1_1DeleteReplicationSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -2147,10 +2162,12 @@ const deserializeAws_json1_1DeleteReplicationSubnetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2199,7 @@ const deserializeAws_json1_1DeleteReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -2193,10 +2209,12 @@ const deserializeAws_json1_1DeleteReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2228,8 +2246,7 @@ const deserializeAws_json1_1DeleteReplicationTaskAssessmentRunCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -2242,10 +2259,12 @@ const deserializeAws_json1_1DeleteReplicationTaskAssessmentRunCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2277,15 +2296,16 @@ const deserializeAws_json1_1DescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2317,8 +2337,7 @@ const deserializeAws_json1_1DescribeApplicableIndividualAssessmentsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -2331,10 +2350,12 @@ const deserializeAws_json1_1DescribeApplicableIndividualAssessmentsCommandError throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2366,18 +2387,19 @@ const deserializeAws_json1_1DescribeCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2409,18 +2431,19 @@ const deserializeAws_json1_1DescribeConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2452,18 +2475,19 @@ const deserializeAws_json1_1DescribeEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2495,15 +2519,16 @@ const deserializeAws_json1_1DescribeEndpointSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2535,15 +2560,16 @@ const deserializeAws_json1_1DescribeEndpointTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2575,15 +2601,16 @@ const deserializeAws_json1_1DescribeEventCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2615,15 +2642,16 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2655,18 +2683,19 @@ const deserializeAws_json1_1DescribeEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2698,18 +2727,19 @@ const deserializeAws_json1_1DescribeFleetAdvisorCollectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2741,18 +2771,19 @@ const deserializeAws_json1_1DescribeFleetAdvisorDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2784,18 +2815,19 @@ const deserializeAws_json1_1DescribeFleetAdvisorLsaAnalysisCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2827,18 +2859,19 @@ const deserializeAws_json1_1DescribeFleetAdvisorSchemaObjectSummaryCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2870,18 +2903,19 @@ const deserializeAws_json1_1DescribeFleetAdvisorSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": throw await deserializeAws_json1_1InvalidResourceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2913,15 +2947,16 @@ const deserializeAws_json1_1DescribeOrderableReplicationInstancesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,18 +2988,19 @@ const deserializeAws_json1_1DescribePendingMaintenanceActionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2996,8 +3032,7 @@ const deserializeAws_json1_1DescribeRefreshSchemasStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3007,10 +3042,12 @@ const deserializeAws_json1_1DescribeRefreshSchemasStatusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3042,18 +3079,19 @@ const deserializeAws_json1_1DescribeReplicationInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3085,8 +3123,7 @@ const deserializeAws_json1_1DescribeReplicationInstanceTaskLogsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3096,10 +3133,12 @@ const deserializeAws_json1_1DescribeReplicationInstanceTaskLogsCommandError = as throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3131,18 +3170,19 @@ const deserializeAws_json1_1DescribeReplicationSubnetGroupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3174,18 +3214,19 @@ const deserializeAws_json1_1DescribeReplicationTaskAssessmentResultsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3217,18 +3258,19 @@ const deserializeAws_json1_1DescribeReplicationTaskAssessmentRunsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3260,18 +3302,19 @@ const deserializeAws_json1_1DescribeReplicationTaskIndividualAssessmentsCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3303,18 +3346,19 @@ const deserializeAws_json1_1DescribeReplicationTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3346,8 +3390,7 @@ const deserializeAws_json1_1DescribeSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3357,10 +3400,12 @@ const deserializeAws_json1_1DescribeSchemasCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3392,8 +3437,7 @@ const deserializeAws_json1_1DescribeTableStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3403,10 +3447,12 @@ const deserializeAws_json1_1DescribeTableStatisticsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3438,8 +3484,7 @@ const deserializeAws_json1_1ImportCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidCertificateFault": case "com.amazonaws.databasemigrationservice#InvalidCertificateFault": @@ -3452,10 +3497,12 @@ const deserializeAws_json1_1ImportCertificateCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3487,18 +3534,19 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3530,8 +3578,7 @@ const deserializeAws_json1_1ModifyEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -3550,10 +3597,12 @@ const deserializeAws_json1_1ModifyEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3585,8 +3634,7 @@ const deserializeAws_json1_1ModifyEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "KMSAccessDeniedFault": case "com.amazonaws.databasemigrationservice#KMSAccessDeniedFault": @@ -3617,10 +3665,12 @@ const deserializeAws_json1_1ModifyEventSubscriptionCommandError = async ( throw await deserializeAws_json1_1SNSNoAuthorizationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3652,8 +3702,7 @@ const deserializeAws_json1_1ModifyReplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -3678,10 +3727,12 @@ const deserializeAws_json1_1ModifyReplicationInstanceCommandError = async ( throw await deserializeAws_json1_1UpgradeDependencyFailureFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3713,8 +3764,7 @@ const deserializeAws_json1_1ModifyReplicationSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -3736,10 +3786,12 @@ const deserializeAws_json1_1ModifyReplicationSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetAlreadyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3771,8 +3823,7 @@ const deserializeAws_json1_1ModifyReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3788,10 +3839,12 @@ const deserializeAws_json1_1ModifyReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3823,8 +3876,7 @@ const deserializeAws_json1_1MoveReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -3843,10 +3895,12 @@ const deserializeAws_json1_1MoveReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3878,8 +3932,7 @@ const deserializeAws_json1_1RebootReplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3889,10 +3942,12 @@ const deserializeAws_json1_1RebootReplicationInstanceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3924,8 +3979,7 @@ const deserializeAws_json1_1RefreshSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3941,10 +3995,12 @@ const deserializeAws_json1_1RefreshSchemasCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3976,8 +4032,7 @@ const deserializeAws_json1_1ReloadTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -3987,10 +4042,12 @@ const deserializeAws_json1_1ReloadTablesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4022,18 +4079,19 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.databasemigrationservice#ResourceNotFoundFault": throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4065,8 +4123,7 @@ const deserializeAws_json1_1RunFleetAdvisorLsaAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -4076,10 +4133,12 @@ const deserializeAws_json1_1RunFleetAdvisorLsaAnalysisCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4111,8 +4170,7 @@ const deserializeAws_json1_1StartReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -4125,10 +4183,12 @@ const deserializeAws_json1_1StartReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4160,8 +4220,7 @@ const deserializeAws_json1_1StartReplicationTaskAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -4171,10 +4230,12 @@ const deserializeAws_json1_1StartReplicationTaskAssessmentCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4206,8 +4267,7 @@ const deserializeAws_json1_1StartReplicationTaskAssessmentRunCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -4247,10 +4307,12 @@ const deserializeAws_json1_1StartReplicationTaskAssessmentRunCommandError = asyn throw await deserializeAws_json1_1S3ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4282,8 +4344,7 @@ const deserializeAws_json1_1StopReplicationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceStateFault": case "com.amazonaws.databasemigrationservice#InvalidResourceStateFault": @@ -4293,10 +4354,12 @@ const deserializeAws_json1_1StopReplicationTaskCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4328,8 +4391,7 @@ const deserializeAws_json1_1TestConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedFault": case "com.amazonaws.databasemigrationservice#AccessDeniedFault": @@ -4348,10 +4410,12 @@ const deserializeAws_json1_1TestConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8995,7 +9059,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9021,6 +9085,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-databrew/src/protocols/Aws_restJson1.ts b/clients/client-databrew/src/protocols/Aws_restJson1.ts index 8349b7e2f61dd..4c36f545d6014 100644 --- a/clients/client-databrew/src/protocols/Aws_restJson1.ts +++ b/clients/client-databrew/src/protocols/Aws_restJson1.ts @@ -1614,8 +1614,7 @@ const deserializeAws_restJson1BatchDeleteRecipeVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -1628,10 +1627,12 @@ const deserializeAws_restJson1BatchDeleteRecipeVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1664,8 +1665,7 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -1681,10 +1681,12 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1717,8 +1719,7 @@ const deserializeAws_restJson1CreateProfileJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -1737,10 +1738,12 @@ const deserializeAws_restJson1CreateProfileJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1773,8 +1776,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -1790,10 +1792,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1830,7 @@ const deserializeAws_restJson1CreateRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -1840,10 +1843,12 @@ const deserializeAws_restJson1CreateRecipeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1876,8 +1881,7 @@ const deserializeAws_restJson1CreateRecipeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -1896,10 +1900,12 @@ const deserializeAws_restJson1CreateRecipeJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1932,8 +1938,7 @@ const deserializeAws_restJson1CreateRulesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -1946,10 +1951,12 @@ const deserializeAws_restJson1CreateRulesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1982,8 +1989,7 @@ const deserializeAws_restJson1CreateScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -1996,10 +2002,12 @@ const deserializeAws_restJson1CreateScheduleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2032,8 +2040,7 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -2046,10 +2053,12 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2082,8 +2091,7 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -2096,10 +2104,12 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2132,8 +2142,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -2146,10 +2155,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2186,8 +2197,7 @@ const deserializeAws_restJson1DeleteRecipeVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -2200,10 +2210,12 @@ const deserializeAws_restJson1DeleteRecipeVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2236,8 +2248,7 @@ const deserializeAws_restJson1DeleteRulesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -2250,10 +2261,12 @@ const deserializeAws_restJson1DeleteRulesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2286,8 +2299,7 @@ const deserializeAws_restJson1DeleteScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2297,10 +2309,12 @@ const deserializeAws_restJson1DeleteScheduleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2377,8 +2391,7 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2388,10 +2401,12 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2519,8 +2534,7 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2530,10 +2544,12 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2641,8 +2657,7 @@ const deserializeAws_restJson1DescribeJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2652,10 +2667,12 @@ const deserializeAws_restJson1DescribeJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2740,8 +2757,7 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2751,10 +2767,12 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2835,8 +2853,7 @@ const deserializeAws_restJson1DescribeRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2846,10 +2863,12 @@ const deserializeAws_restJson1DescribeRecipeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2918,8 +2937,7 @@ const deserializeAws_restJson1DescribeRulesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -2929,10 +2947,12 @@ const deserializeAws_restJson1DescribeRulesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2997,8 +3017,7 @@ const deserializeAws_restJson1DescribeScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3008,10 +3027,12 @@ const deserializeAws_restJson1DescribeScheduleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3048,18 +3069,19 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3096,8 +3118,7 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3107,10 +3128,12 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3147,18 +3170,19 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3195,18 +3219,19 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3243,18 +3268,19 @@ const deserializeAws_restJson1ListRecipesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3291,18 +3317,19 @@ const deserializeAws_restJson1ListRecipeVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3339,8 +3366,7 @@ const deserializeAws_restJson1ListRulesetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3350,10 +3376,12 @@ const deserializeAws_restJson1ListRulesetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3390,18 +3418,19 @@ const deserializeAws_restJson1ListSchedulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.databrew#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3434,8 +3463,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.databrew#InternalServerException": @@ -3448,10 +3476,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3484,8 +3514,7 @@ const deserializeAws_restJson1PublishRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3498,10 +3527,12 @@ const deserializeAws_restJson1PublishRecipeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3542,8 +3573,7 @@ const deserializeAws_restJson1SendProjectSessionActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -3556,10 +3586,12 @@ const deserializeAws_restJson1SendProjectSessionActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3592,8 +3624,7 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -3609,10 +3640,12 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3649,8 +3682,7 @@ const deserializeAws_restJson1StartProjectSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.databrew#ConflictException": @@ -3666,10 +3698,12 @@ const deserializeAws_restJson1StartProjectSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3702,8 +3736,7 @@ const deserializeAws_restJson1StopJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3713,10 +3746,12 @@ const deserializeAws_restJson1StopJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3745,8 +3780,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.databrew#InternalServerException": @@ -3759,10 +3793,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3791,8 +3827,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.databrew#InternalServerException": @@ -3805,10 +3840,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3841,8 +3878,7 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -3855,10 +3891,12 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3891,8 +3929,7 @@ const deserializeAws_restJson1UpdateProfileJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -3905,10 +3942,12 @@ const deserializeAws_restJson1UpdateProfileJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3945,8 +3984,7 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -3956,10 +3994,12 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3992,8 +4032,7 @@ const deserializeAws_restJson1UpdateRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -4003,10 +4042,12 @@ const deserializeAws_restJson1UpdateRecipeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4039,8 +4080,7 @@ const deserializeAws_restJson1UpdateRecipeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.databrew#AccessDeniedException": @@ -4053,10 +4093,12 @@ const deserializeAws_restJson1UpdateRecipeJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4089,8 +4131,7 @@ const deserializeAws_restJson1UpdateRulesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -4100,10 +4141,12 @@ const deserializeAws_restJson1UpdateRulesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4136,8 +4179,7 @@ const deserializeAws_restJson1UpdateScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.databrew#ResourceNotFoundException": @@ -4150,10 +4192,12 @@ const deserializeAws_restJson1UpdateScheduleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6058,7 +6102,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6084,6 +6128,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-dataexchange/src/protocols/Aws_restJson1.ts b/clients/client-dataexchange/src/protocols/Aws_restJson1.ts index d943d68eafa0c..b23209cbf761c 100644 --- a/clients/client-dataexchange/src/protocols/Aws_restJson1.ts +++ b/clients/client-dataexchange/src/protocols/Aws_restJson1.ts @@ -1128,8 +1128,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.dataexchange#ConflictException": @@ -1148,10 +1147,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1224,8 +1225,7 @@ const deserializeAws_restJson1CreateDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1244,10 +1244,12 @@ const deserializeAws_restJson1CreateDataSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1302,7 @@ const deserializeAws_restJson1CreateEventActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1320,10 +1321,12 @@ const deserializeAws_restJson1CreateEventActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1384,8 +1387,7 @@ const deserializeAws_restJson1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1407,10 +1409,12 @@ const deserializeAws_restJson1CreateJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1487,8 +1491,7 @@ const deserializeAws_restJson1CreateRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1507,10 +1510,12 @@ const deserializeAws_restJson1CreateRevisionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1539,8 +1544,7 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1562,10 +1566,12 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1594,8 +1600,7 @@ const deserializeAws_restJson1DeleteDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1617,10 +1622,12 @@ const deserializeAws_restJson1DeleteDataSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1649,8 +1656,7 @@ const deserializeAws_restJson1DeleteEventActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -1666,10 +1672,12 @@ const deserializeAws_restJson1DeleteEventActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1698,8 +1706,7 @@ const deserializeAws_restJson1DeleteRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -1721,10 +1728,12 @@ const deserializeAws_restJson1DeleteRevisionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1793,8 +1802,7 @@ const deserializeAws_restJson1GetAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -1810,10 +1818,12 @@ const deserializeAws_restJson1GetAssetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1886,8 +1896,7 @@ const deserializeAws_restJson1GetDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -1903,10 +1912,12 @@ const deserializeAws_restJson1GetDataSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1959,8 +1970,7 @@ const deserializeAws_restJson1GetEventActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -1976,10 +1986,12 @@ const deserializeAws_restJson1GetEventActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2040,8 +2052,7 @@ const deserializeAws_restJson1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2057,10 +2068,12 @@ const deserializeAws_restJson1GetJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2137,8 +2150,7 @@ const deserializeAws_restJson1GetRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2154,10 +2166,12 @@ const deserializeAws_restJson1GetRevisionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2194,8 +2208,7 @@ const deserializeAws_restJson1ListDataSetRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2211,10 +2224,12 @@ const deserializeAws_restJson1ListDataSetRevisionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2266,7 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2268,10 +2282,12 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2308,8 +2324,7 @@ const deserializeAws_restJson1ListEventActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2325,10 +2340,12 @@ const deserializeAws_restJson1ListEventActionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2365,8 +2382,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2382,10 +2398,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2422,8 +2440,7 @@ const deserializeAws_restJson1ListRevisionAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dataexchange#InternalServerException": @@ -2439,10 +2456,12 @@ const deserializeAws_restJson1ListRevisionAssetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2475,15 +2494,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2556,8 +2576,7 @@ const deserializeAws_restJson1RevokeRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -2579,10 +2598,12 @@ const deserializeAws_restJson1RevokeRevisionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2622,8 +2643,7 @@ const deserializeAws_restJson1SendApiAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -2642,10 +2662,12 @@ const deserializeAws_restJson1SendApiAssetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2674,8 +2696,7 @@ const deserializeAws_restJson1StartJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -2697,10 +2718,12 @@ const deserializeAws_restJson1StartJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2729,15 +2752,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2766,15 +2790,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2843,8 +2868,7 @@ const deserializeAws_restJson1UpdateAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -2866,10 +2890,12 @@ const deserializeAws_restJson1UpdateAssetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2938,8 +2964,7 @@ const deserializeAws_restJson1UpdateDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -2958,10 +2983,12 @@ const deserializeAws_restJson1UpdateDataSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3014,8 +3041,7 @@ const deserializeAws_restJson1UpdateEventActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -3034,10 +3060,12 @@ const deserializeAws_restJson1UpdateEventActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3110,8 +3138,7 @@ const deserializeAws_restJson1UpdateRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.dataexchange#AccessDeniedException": @@ -3133,10 +3160,12 @@ const deserializeAws_restJson1UpdateRevisionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4242,7 +4271,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4268,6 +4297,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-datasync/src/protocols/Aws_json1_1.ts b/clients/client-datasync/src/protocols/Aws_json1_1.ts index 031c941f4db16..d13975cd0534f 100644 --- a/clients/client-datasync/src/protocols/Aws_json1_1.ts +++ b/clients/client-datasync/src/protocols/Aws_json1_1.ts @@ -792,8 +792,7 @@ const deserializeAws_json1_1CancelTaskExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -803,10 +802,12 @@ const deserializeAws_json1_1CancelTaskExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -838,8 +839,7 @@ const deserializeAws_json1_1CreateAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -849,10 +849,12 @@ const deserializeAws_json1_1CreateAgentCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -884,8 +886,7 @@ const deserializeAws_json1_1CreateLocationEfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -895,10 +896,12 @@ const deserializeAws_json1_1CreateLocationEfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -930,8 +933,7 @@ const deserializeAws_json1_1CreateLocationFsxLustreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -941,10 +943,12 @@ const deserializeAws_json1_1CreateLocationFsxLustreCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -976,8 +980,7 @@ const deserializeAws_json1_1CreateLocationFsxOpenZfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -987,10 +990,12 @@ const deserializeAws_json1_1CreateLocationFsxOpenZfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1022,8 +1027,7 @@ const deserializeAws_json1_1CreateLocationFsxWindowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1033,10 +1037,12 @@ const deserializeAws_json1_1CreateLocationFsxWindowsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1068,8 +1074,7 @@ const deserializeAws_json1_1CreateLocationHdfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1079,10 +1084,12 @@ const deserializeAws_json1_1CreateLocationHdfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1114,8 +1121,7 @@ const deserializeAws_json1_1CreateLocationNfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1125,10 +1131,12 @@ const deserializeAws_json1_1CreateLocationNfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1168,7 @@ const deserializeAws_json1_1CreateLocationObjectStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1171,10 +1178,12 @@ const deserializeAws_json1_1CreateLocationObjectStorageCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1215,7 @@ const deserializeAws_json1_1CreateLocationS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1217,10 +1225,12 @@ const deserializeAws_json1_1CreateLocationS3CommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1252,8 +1262,7 @@ const deserializeAws_json1_1CreateLocationSmbCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1263,10 +1272,12 @@ const deserializeAws_json1_1CreateLocationSmbCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1298,8 +1309,7 @@ const deserializeAws_json1_1CreateTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1309,10 +1319,12 @@ const deserializeAws_json1_1CreateTaskCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1344,8 +1356,7 @@ const deserializeAws_json1_1DeleteAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1355,10 +1366,12 @@ const deserializeAws_json1_1DeleteAgentCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1390,8 +1403,7 @@ const deserializeAws_json1_1DeleteLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1401,10 +1413,12 @@ const deserializeAws_json1_1DeleteLocationCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1436,8 +1450,7 @@ const deserializeAws_json1_1DeleteTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1447,10 +1460,12 @@ const deserializeAws_json1_1DeleteTaskCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1482,8 +1497,7 @@ const deserializeAws_json1_1DescribeAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1493,10 +1507,12 @@ const deserializeAws_json1_1DescribeAgentCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1528,8 +1544,7 @@ const deserializeAws_json1_1DescribeLocationEfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1539,10 +1554,12 @@ const deserializeAws_json1_1DescribeLocationEfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1574,8 +1591,7 @@ const deserializeAws_json1_1DescribeLocationFsxLustreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1585,10 +1601,12 @@ const deserializeAws_json1_1DescribeLocationFsxLustreCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1620,8 +1638,7 @@ const deserializeAws_json1_1DescribeLocationFsxOpenZfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1631,10 +1648,12 @@ const deserializeAws_json1_1DescribeLocationFsxOpenZfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1666,8 +1685,7 @@ const deserializeAws_json1_1DescribeLocationFsxWindowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1677,10 +1695,12 @@ const deserializeAws_json1_1DescribeLocationFsxWindowsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1712,8 +1732,7 @@ const deserializeAws_json1_1DescribeLocationHdfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1723,10 +1742,12 @@ const deserializeAws_json1_1DescribeLocationHdfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1758,8 +1779,7 @@ const deserializeAws_json1_1DescribeLocationNfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1769,10 +1789,12 @@ const deserializeAws_json1_1DescribeLocationNfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1804,8 +1826,7 @@ const deserializeAws_json1_1DescribeLocationObjectStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1815,10 +1836,12 @@ const deserializeAws_json1_1DescribeLocationObjectStorageCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1850,8 +1873,7 @@ const deserializeAws_json1_1DescribeLocationS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1861,10 +1883,12 @@ const deserializeAws_json1_1DescribeLocationS3CommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1896,8 +1920,7 @@ const deserializeAws_json1_1DescribeLocationSmbCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1907,10 +1930,12 @@ const deserializeAws_json1_1DescribeLocationSmbCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1942,8 +1967,7 @@ const deserializeAws_json1_1DescribeTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1953,10 +1977,12 @@ const deserializeAws_json1_1DescribeTaskCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1988,8 +2014,7 @@ const deserializeAws_json1_1DescribeTaskExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -1999,10 +2024,12 @@ const deserializeAws_json1_1DescribeTaskExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2034,8 +2061,7 @@ const deserializeAws_json1_1ListAgentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2045,10 +2071,12 @@ const deserializeAws_json1_1ListAgentsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2080,8 +2108,7 @@ const deserializeAws_json1_1ListLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2091,10 +2118,12 @@ const deserializeAws_json1_1ListLocationsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2126,8 +2155,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2137,10 +2165,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2172,8 +2202,7 @@ const deserializeAws_json1_1ListTaskExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2183,10 +2212,12 @@ const deserializeAws_json1_1ListTaskExecutionsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2218,8 +2249,7 @@ const deserializeAws_json1_1ListTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2229,10 +2259,12 @@ const deserializeAws_json1_1ListTasksCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2264,8 +2296,7 @@ const deserializeAws_json1_1StartTaskExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2275,10 +2306,12 @@ const deserializeAws_json1_1StartTaskExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2310,8 +2343,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2321,10 +2353,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2356,8 +2390,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2367,10 +2400,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2402,8 +2437,7 @@ const deserializeAws_json1_1UpdateAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2413,10 +2447,12 @@ const deserializeAws_json1_1UpdateAgentCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2448,8 +2484,7 @@ const deserializeAws_json1_1UpdateLocationHdfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2459,10 +2494,12 @@ const deserializeAws_json1_1UpdateLocationHdfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2494,8 +2531,7 @@ const deserializeAws_json1_1UpdateLocationNfsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2505,10 +2541,12 @@ const deserializeAws_json1_1UpdateLocationNfsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2540,8 +2578,7 @@ const deserializeAws_json1_1UpdateLocationObjectStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2551,10 +2588,12 @@ const deserializeAws_json1_1UpdateLocationObjectStorageCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2586,8 +2625,7 @@ const deserializeAws_json1_1UpdateLocationSmbCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2597,10 +2635,12 @@ const deserializeAws_json1_1UpdateLocationSmbCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2632,8 +2672,7 @@ const deserializeAws_json1_1UpdateTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2643,10 +2682,12 @@ const deserializeAws_json1_1UpdateTaskCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2678,8 +2719,7 @@ const deserializeAws_json1_1UpdateTaskExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.datasync#InternalException": @@ -2689,10 +2729,12 @@ const deserializeAws_json1_1UpdateTaskExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4461,7 +4503,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4487,6 +4529,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-dax/src/protocols/Aws_json1_1.ts b/clients/client-dax/src/protocols/Aws_json1_1.ts index 00bd8f4d88810..ceb4f9a63d672 100644 --- a/clients/client-dax/src/protocols/Aws_json1_1.ts +++ b/clients/client-dax/src/protocols/Aws_json1_1.ts @@ -448,8 +448,7 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterAlreadyExistsFault": case "com.amazonaws.dax#ClusterAlreadyExistsFault": @@ -498,10 +497,12 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -533,8 +534,7 @@ const deserializeAws_json1_1CreateParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -556,10 +556,12 @@ const deserializeAws_json1_1CreateParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -591,8 +593,7 @@ const deserializeAws_json1_1CreateSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubnet": case "com.amazonaws.dax#InvalidSubnet": @@ -611,10 +612,12 @@ const deserializeAws_json1_1CreateSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -646,8 +649,7 @@ const deserializeAws_json1_1DecreaseReplicationFactorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -669,10 +671,12 @@ const deserializeAws_json1_1DecreaseReplicationFactorCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -704,8 +708,7 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -724,10 +727,12 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -759,8 +764,7 @@ const deserializeAws_json1_1DeleteParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -779,10 +783,12 @@ const deserializeAws_json1_1DeleteParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -814,8 +820,7 @@ const deserializeAws_json1_1DeleteSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceLinkedRoleNotFoundFault": case "com.amazonaws.dax#ServiceLinkedRoleNotFoundFault": @@ -828,10 +833,12 @@ const deserializeAws_json1_1DeleteSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -863,8 +870,7 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -880,10 +886,12 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -915,8 +923,7 @@ const deserializeAws_json1_1DescribeDefaultParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -929,10 +936,12 @@ const deserializeAws_json1_1DescribeDefaultParametersCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -964,8 +973,7 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -978,10 +986,12 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1013,8 +1023,7 @@ const deserializeAws_json1_1DescribeParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -1030,10 +1039,12 @@ const deserializeAws_json1_1DescribeParameterGroupsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1065,8 +1076,7 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -1082,10 +1092,12 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1117,8 +1129,7 @@ const deserializeAws_json1_1DescribeSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceLinkedRoleNotFoundFault": case "com.amazonaws.dax#ServiceLinkedRoleNotFoundFault": @@ -1128,10 +1139,12 @@ const deserializeAws_json1_1DescribeSubnetGroupsCommandError = async ( throw await deserializeAws_json1_1SubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1163,8 +1176,7 @@ const deserializeAws_json1_1IncreaseReplicationFactorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1195,10 +1207,12 @@ const deserializeAws_json1_1IncreaseReplicationFactorCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1230,8 +1244,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1253,10 +1266,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1288,8 +1303,7 @@ const deserializeAws_json1_1RebootNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1311,10 +1325,12 @@ const deserializeAws_json1_1RebootNodeCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1346,8 +1362,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1372,10 +1387,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1407,8 +1424,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1433,10 +1449,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TagNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1468,8 +1486,7 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.dax#ClusterNotFoundFault": @@ -1494,10 +1511,12 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1529,8 +1548,7 @@ const deserializeAws_json1_1UpdateParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.dax#InvalidParameterCombinationException": @@ -1549,10 +1567,12 @@ const deserializeAws_json1_1UpdateParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1584,8 +1604,7 @@ const deserializeAws_json1_1UpdateSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubnet": case "com.amazonaws.dax#InvalidSubnet": @@ -1604,10 +1623,12 @@ const deserializeAws_json1_1UpdateSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3184,7 +3205,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3210,6 +3231,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-detective/src/protocols/Aws_restJson1.ts b/clients/client-detective/src/protocols/Aws_restJson1.ts index 72f410310a35f..d897fcdb0effe 100644 --- a/clients/client-detective/src/protocols/Aws_restJson1.ts +++ b/clients/client-detective/src/protocols/Aws_restJson1.ts @@ -620,8 +620,7 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -637,10 +636,12 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -673,8 +674,7 @@ const deserializeAws_restJson1CreateGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -687,10 +687,12 @@ const deserializeAws_restJson1CreateGraphCommandError = async ( throw await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -727,8 +729,7 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -744,10 +745,12 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -776,8 +779,7 @@ const deserializeAws_restJson1DeleteGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -790,10 +792,12 @@ const deserializeAws_restJson1DeleteGraphCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -830,8 +834,7 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -847,10 +850,12 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -883,8 +888,7 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -897,10 +901,12 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -929,8 +935,7 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -943,10 +948,12 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -975,8 +982,7 @@ const deserializeAws_restJson1DisassociateMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -992,10 +998,12 @@ const deserializeAws_restJson1DisassociateMembershipCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1024,8 +1032,7 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1038,10 +1045,12 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1078,8 +1087,7 @@ const deserializeAws_restJson1GetMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1092,10 +1100,12 @@ const deserializeAws_restJson1GetMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1132,8 +1142,7 @@ const deserializeAws_restJson1ListGraphsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1143,10 +1152,12 @@ const deserializeAws_restJson1ListGraphsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1183,8 +1194,7 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1194,10 +1204,12 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1234,8 +1246,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1248,10 +1259,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1288,8 +1301,7 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1302,10 +1314,12 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1338,8 +1352,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1352,10 +1365,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1384,8 +1399,7 @@ const deserializeAws_restJson1RejectInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -1401,10 +1415,12 @@ const deserializeAws_restJson1RejectInvitationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1433,8 +1449,7 @@ const deserializeAws_restJson1StartMonitoringMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.detective#ConflictException": @@ -1453,10 +1468,12 @@ const deserializeAws_restJson1StartMonitoringMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1485,8 +1502,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1499,10 +1515,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1531,8 +1549,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1545,10 +1562,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1596,7 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.detective#InternalServerException": @@ -1591,10 +1609,12 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1905,7 +1925,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1931,6 +1951,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-device-farm/src/protocols/Aws_json1_1.ts b/clients/client-device-farm/src/protocols/Aws_json1_1.ts index 3256195008576..c2c0aad937c11 100644 --- a/clients/client-device-farm/src/protocols/Aws_json1_1.ts +++ b/clients/client-device-farm/src/protocols/Aws_json1_1.ts @@ -1440,8 +1440,7 @@ const deserializeAws_json1_1CreateDevicePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1457,10 +1456,12 @@ const deserializeAws_json1_1CreateDevicePoolCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1492,8 +1493,7 @@ const deserializeAws_json1_1CreateInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1509,10 +1509,12 @@ const deserializeAws_json1_1CreateInstanceProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1546,7 @@ const deserializeAws_json1_1CreateNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1561,10 +1562,12 @@ const deserializeAws_json1_1CreateNetworkProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1596,8 +1599,7 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1616,10 +1618,12 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( throw await deserializeAws_json1_1TagOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1655,7 @@ const deserializeAws_json1_1CreateRemoteAccessSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1668,10 +1671,12 @@ const deserializeAws_json1_1CreateRemoteAccessSessionCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1703,8 +1708,7 @@ const deserializeAws_json1_1CreateTestGridProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1717,10 +1721,12 @@ const deserializeAws_json1_1CreateTestGridProjectCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1752,8 +1758,7 @@ const deserializeAws_json1_1CreateTestGridUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1766,10 +1771,12 @@ const deserializeAws_json1_1CreateTestGridUrlCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1801,8 +1808,7 @@ const deserializeAws_json1_1CreateUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1818,10 +1824,12 @@ const deserializeAws_json1_1CreateUploadCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1853,8 +1861,7 @@ const deserializeAws_json1_1CreateVPCEConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1867,10 +1874,12 @@ const deserializeAws_json1_1CreateVPCEConfigurationCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1902,8 +1911,7 @@ const deserializeAws_json1_1DeleteDevicePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1919,10 +1927,12 @@ const deserializeAws_json1_1DeleteDevicePoolCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1954,8 +1964,7 @@ const deserializeAws_json1_1DeleteInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -1971,10 +1980,12 @@ const deserializeAws_json1_1DeleteInstanceProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2006,8 +2017,7 @@ const deserializeAws_json1_1DeleteNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2023,10 +2033,12 @@ const deserializeAws_json1_1DeleteNetworkProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2058,8 +2070,7 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2075,10 +2086,12 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2110,8 +2123,7 @@ const deserializeAws_json1_1DeleteRemoteAccessSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2127,10 +2139,12 @@ const deserializeAws_json1_1DeleteRemoteAccessSessionCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2162,8 +2176,7 @@ const deserializeAws_json1_1DeleteRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2179,10 +2192,12 @@ const deserializeAws_json1_1DeleteRunCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2214,8 +2229,7 @@ const deserializeAws_json1_1DeleteTestGridProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2231,10 +2245,12 @@ const deserializeAws_json1_1DeleteTestGridProjectCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2266,8 +2282,7 @@ const deserializeAws_json1_1DeleteUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2283,10 +2298,12 @@ const deserializeAws_json1_1DeleteUploadCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2318,8 +2335,7 @@ const deserializeAws_json1_1DeleteVPCEConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2335,10 +2351,12 @@ const deserializeAws_json1_1DeleteVPCEConfigurationCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2370,8 +2388,7 @@ const deserializeAws_json1_1GetAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2387,10 +2404,12 @@ const deserializeAws_json1_1GetAccountSettingsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2422,8 +2441,7 @@ const deserializeAws_json1_1GetDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2439,10 +2457,12 @@ const deserializeAws_json1_1GetDeviceCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2474,8 +2494,7 @@ const deserializeAws_json1_1GetDeviceInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2491,10 +2510,12 @@ const deserializeAws_json1_1GetDeviceInstanceCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2526,8 +2547,7 @@ const deserializeAws_json1_1GetDevicePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2543,10 +2563,12 @@ const deserializeAws_json1_1GetDevicePoolCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2578,8 +2600,7 @@ const deserializeAws_json1_1GetDevicePoolCompatibilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2595,10 +2616,12 @@ const deserializeAws_json1_1GetDevicePoolCompatibilityCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2630,8 +2653,7 @@ const deserializeAws_json1_1GetInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2647,10 +2669,12 @@ const deserializeAws_json1_1GetInstanceProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2682,8 +2706,7 @@ const deserializeAws_json1_1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2699,10 +2722,12 @@ const deserializeAws_json1_1GetJobCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2734,8 +2759,7 @@ const deserializeAws_json1_1GetNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2751,10 +2775,12 @@ const deserializeAws_json1_1GetNetworkProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2786,8 +2812,7 @@ const deserializeAws_json1_1GetOfferingStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2806,10 +2831,12 @@ const deserializeAws_json1_1GetOfferingStatusCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2841,8 +2868,7 @@ const deserializeAws_json1_1GetProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2858,10 +2884,12 @@ const deserializeAws_json1_1GetProjectCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2893,8 +2921,7 @@ const deserializeAws_json1_1GetRemoteAccessSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2910,10 +2937,12 @@ const deserializeAws_json1_1GetRemoteAccessSessionCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2945,8 +2974,7 @@ const deserializeAws_json1_1GetRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -2962,10 +2990,12 @@ const deserializeAws_json1_1GetRunCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2997,8 +3027,7 @@ const deserializeAws_json1_1GetSuiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3014,10 +3043,12 @@ const deserializeAws_json1_1GetSuiteCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3049,8 +3080,7 @@ const deserializeAws_json1_1GetTestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3066,10 +3096,12 @@ const deserializeAws_json1_1GetTestCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3101,8 +3133,7 @@ const deserializeAws_json1_1GetTestGridProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3115,10 +3146,12 @@ const deserializeAws_json1_1GetTestGridProjectCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3150,8 +3183,7 @@ const deserializeAws_json1_1GetTestGridSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3164,10 +3196,12 @@ const deserializeAws_json1_1GetTestGridSessionCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3199,8 +3233,7 @@ const deserializeAws_json1_1GetUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3216,10 +3249,12 @@ const deserializeAws_json1_1GetUploadCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3251,8 +3286,7 @@ const deserializeAws_json1_1GetVPCEConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3265,10 +3299,12 @@ const deserializeAws_json1_1GetVPCEConfigurationCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3300,8 +3336,7 @@ const deserializeAws_json1_1InstallToRemoteAccessSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3317,10 +3352,12 @@ const deserializeAws_json1_1InstallToRemoteAccessSessionCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3352,8 +3389,7 @@ const deserializeAws_json1_1ListArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3369,10 +3405,12 @@ const deserializeAws_json1_1ListArtifactsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3404,8 +3442,7 @@ const deserializeAws_json1_1ListDeviceInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3421,10 +3458,12 @@ const deserializeAws_json1_1ListDeviceInstancesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3456,8 +3495,7 @@ const deserializeAws_json1_1ListDevicePoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3473,10 +3511,12 @@ const deserializeAws_json1_1ListDevicePoolsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3508,8 +3548,7 @@ const deserializeAws_json1_1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3525,10 +3564,12 @@ const deserializeAws_json1_1ListDevicesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3560,8 +3601,7 @@ const deserializeAws_json1_1ListInstanceProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3577,10 +3617,12 @@ const deserializeAws_json1_1ListInstanceProfilesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3612,8 +3654,7 @@ const deserializeAws_json1_1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3629,10 +3670,12 @@ const deserializeAws_json1_1ListJobsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3664,8 +3707,7 @@ const deserializeAws_json1_1ListNetworkProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3681,10 +3723,12 @@ const deserializeAws_json1_1ListNetworkProfilesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3716,8 +3760,7 @@ const deserializeAws_json1_1ListOfferingPromotionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3736,10 +3779,12 @@ const deserializeAws_json1_1ListOfferingPromotionsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3771,8 +3816,7 @@ const deserializeAws_json1_1ListOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3791,10 +3835,12 @@ const deserializeAws_json1_1ListOfferingsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3826,8 +3872,7 @@ const deserializeAws_json1_1ListOfferingTransactionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3846,10 +3891,12 @@ const deserializeAws_json1_1ListOfferingTransactionsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3881,8 +3928,7 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3898,10 +3944,12 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3933,8 +3981,7 @@ const deserializeAws_json1_1ListRemoteAccessSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -3950,10 +3997,12 @@ const deserializeAws_json1_1ListRemoteAccessSessionsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3985,8 +4034,7 @@ const deserializeAws_json1_1ListRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4002,10 +4050,12 @@ const deserializeAws_json1_1ListRunsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4037,8 +4087,7 @@ const deserializeAws_json1_1ListSamplesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4054,10 +4103,12 @@ const deserializeAws_json1_1ListSamplesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4089,8 +4140,7 @@ const deserializeAws_json1_1ListSuitesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4106,10 +4156,12 @@ const deserializeAws_json1_1ListSuitesCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4141,8 +4193,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4155,10 +4206,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TagOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4190,8 +4243,7 @@ const deserializeAws_json1_1ListTestGridProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4201,10 +4253,12 @@ const deserializeAws_json1_1ListTestGridProjectsCommandError = async ( throw await deserializeAws_json1_1InternalServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4236,8 +4290,7 @@ const deserializeAws_json1_1ListTestGridSessionActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4250,10 +4303,12 @@ const deserializeAws_json1_1ListTestGridSessionActionsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4285,8 +4340,7 @@ const deserializeAws_json1_1ListTestGridSessionArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4299,10 +4353,12 @@ const deserializeAws_json1_1ListTestGridSessionArtifactsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4334,8 +4390,7 @@ const deserializeAws_json1_1ListTestGridSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4348,10 +4403,12 @@ const deserializeAws_json1_1ListTestGridSessionsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4383,8 +4440,7 @@ const deserializeAws_json1_1ListTestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4400,10 +4456,12 @@ const deserializeAws_json1_1ListTestsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4435,8 +4493,7 @@ const deserializeAws_json1_1ListUniqueProblemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4452,10 +4509,12 @@ const deserializeAws_json1_1ListUniqueProblemsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4487,8 +4546,7 @@ const deserializeAws_json1_1ListUploadsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4504,10 +4562,12 @@ const deserializeAws_json1_1ListUploadsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4539,8 +4599,7 @@ const deserializeAws_json1_1ListVPCEConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4550,10 +4609,12 @@ const deserializeAws_json1_1ListVPCEConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4585,8 +4646,7 @@ const deserializeAws_json1_1PurchaseOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4605,10 +4665,12 @@ const deserializeAws_json1_1PurchaseOfferingCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4640,8 +4702,7 @@ const deserializeAws_json1_1RenewOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4660,10 +4721,12 @@ const deserializeAws_json1_1RenewOfferingCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4695,8 +4758,7 @@ const deserializeAws_json1_1ScheduleRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4715,10 +4777,12 @@ const deserializeAws_json1_1ScheduleRunCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4750,8 +4814,7 @@ const deserializeAws_json1_1StopJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4767,10 +4830,12 @@ const deserializeAws_json1_1StopJobCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4802,8 +4867,7 @@ const deserializeAws_json1_1StopRemoteAccessSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4819,10 +4883,12 @@ const deserializeAws_json1_1StopRemoteAccessSessionCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4854,8 +4920,7 @@ const deserializeAws_json1_1StopRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4871,10 +4936,12 @@ const deserializeAws_json1_1StopRunCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4906,8 +4973,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4926,10 +4992,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4961,8 +5029,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -4975,10 +5042,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TagOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5010,8 +5079,7 @@ const deserializeAws_json1_1UpdateDeviceInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5027,10 +5095,12 @@ const deserializeAws_json1_1UpdateDeviceInstanceCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5062,8 +5132,7 @@ const deserializeAws_json1_1UpdateDevicePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5079,10 +5148,12 @@ const deserializeAws_json1_1UpdateDevicePoolCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5114,8 +5185,7 @@ const deserializeAws_json1_1UpdateInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5131,10 +5201,12 @@ const deserializeAws_json1_1UpdateInstanceProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5166,8 +5238,7 @@ const deserializeAws_json1_1UpdateNetworkProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5183,10 +5254,12 @@ const deserializeAws_json1_1UpdateNetworkProfileCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5218,8 +5291,7 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5235,10 +5307,12 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5270,8 +5344,7 @@ const deserializeAws_json1_1UpdateTestGridProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5287,10 +5360,12 @@ const deserializeAws_json1_1UpdateTestGridProjectCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5322,8 +5397,7 @@ const deserializeAws_json1_1UpdateUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5339,10 +5413,12 @@ const deserializeAws_json1_1UpdateUploadCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5374,8 +5450,7 @@ const deserializeAws_json1_1UpdateVPCEConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ArgumentException": case "com.amazonaws.devicefarm#ArgumentException": @@ -5391,10 +5466,12 @@ const deserializeAws_json1_1UpdateVPCEConfigurationCommandError = async ( throw await deserializeAws_json1_1ServiceAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8788,7 +8865,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8814,6 +8891,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-devops-guru/src/protocols/Aws_restJson1.ts b/clients/client-devops-guru/src/protocols/Aws_restJson1.ts index 8a507d712f9fd..18486bc789620 100644 --- a/clients/client-devops-guru/src/protocols/Aws_restJson1.ts +++ b/clients/client-devops-guru/src/protocols/Aws_restJson1.ts @@ -1079,8 +1079,7 @@ const deserializeAws_restJson1AddNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1105,10 +1104,12 @@ const deserializeAws_restJson1AddNotificationChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1137,8 +1138,7 @@ const deserializeAws_restJson1DeleteInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1160,10 +1160,12 @@ const deserializeAws_restJson1DeleteInsightCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1208,8 +1210,7 @@ const deserializeAws_restJson1DescribeAccountHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1225,10 +1226,12 @@ const deserializeAws_restJson1DescribeAccountHealthCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1269,8 +1272,7 @@ const deserializeAws_restJson1DescribeAccountOverviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1286,10 +1288,12 @@ const deserializeAws_restJson1DescribeAccountOverviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1326,8 +1330,7 @@ const deserializeAws_restJson1DescribeAnomalyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1346,10 +1349,12 @@ const deserializeAws_restJson1DescribeAnomalyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1382,8 +1387,7 @@ const deserializeAws_restJson1DescribeEventSourcesConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1399,10 +1403,12 @@ const deserializeAws_restJson1DescribeEventSourcesConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1435,8 +1441,7 @@ const deserializeAws_restJson1DescribeFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1455,10 +1460,12 @@ const deserializeAws_restJson1DescribeFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1495,8 +1502,7 @@ const deserializeAws_restJson1DescribeInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1515,10 +1521,12 @@ const deserializeAws_restJson1DescribeInsightCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1563,8 +1571,7 @@ const deserializeAws_restJson1DescribeOrganizationHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1580,10 +1587,12 @@ const deserializeAws_restJson1DescribeOrganizationHealthCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1620,8 +1629,7 @@ const deserializeAws_restJson1DescribeOrganizationOverviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1637,10 +1645,12 @@ const deserializeAws_restJson1DescribeOrganizationOverviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1689,8 +1699,7 @@ const deserializeAws_restJson1DescribeOrganizationResourceCollectionHealthComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1706,10 +1715,12 @@ const deserializeAws_restJson1DescribeOrganizationResourceCollectionHealthComman throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1754,8 +1765,7 @@ const deserializeAws_restJson1DescribeResourceCollectionHealthCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1771,10 +1781,12 @@ const deserializeAws_restJson1DescribeResourceCollectionHealthCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1807,8 +1819,7 @@ const deserializeAws_restJson1DescribeServiceIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1824,10 +1835,12 @@ const deserializeAws_restJson1DescribeServiceIntegrationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1883,8 +1896,7 @@ const deserializeAws_restJson1GetCostEstimationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1903,10 +1915,12 @@ const deserializeAws_restJson1GetCostEstimationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1957,7 @@ const deserializeAws_restJson1GetResourceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -1963,10 +1976,12 @@ const deserializeAws_restJson1GetResourceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2007,8 +2022,7 @@ const deserializeAws_restJson1ListAnomaliesForInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2027,10 +2041,12 @@ const deserializeAws_restJson1ListAnomaliesForInsightCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2083,7 @@ const deserializeAws_restJson1ListEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2087,10 +2102,12 @@ const deserializeAws_restJson1ListEventsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2131,8 +2148,7 @@ const deserializeAws_restJson1ListInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2148,10 +2164,12 @@ const deserializeAws_restJson1ListInsightsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2188,8 +2206,7 @@ const deserializeAws_restJson1ListNotificationChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2205,10 +2222,12 @@ const deserializeAws_restJson1ListNotificationChannelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2249,8 +2268,7 @@ const deserializeAws_restJson1ListOrganizationInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2266,10 +2284,12 @@ const deserializeAws_restJson1ListOrganizationInsightsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2306,8 +2326,7 @@ const deserializeAws_restJson1ListRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2326,10 +2345,12 @@ const deserializeAws_restJson1ListRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2358,8 +2379,7 @@ const deserializeAws_restJson1PutFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2381,10 +2401,12 @@ const deserializeAws_restJson1PutFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2413,8 +2435,7 @@ const deserializeAws_restJson1RemoveNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2436,10 +2457,12 @@ const deserializeAws_restJson1RemoveNotificationChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2503,7 @@ const deserializeAws_restJson1SearchInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2497,10 +2519,12 @@ const deserializeAws_restJson1SearchInsightsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2541,8 +2565,7 @@ const deserializeAws_restJson1SearchOrganizationInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2558,10 +2581,12 @@ const deserializeAws_restJson1SearchOrganizationInsightsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2590,8 +2615,7 @@ const deserializeAws_restJson1StartCostEstimationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2613,10 +2637,12 @@ const deserializeAws_restJson1StartCostEstimationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2645,8 +2671,7 @@ const deserializeAws_restJson1UpdateEventSourcesConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2662,10 +2687,12 @@ const deserializeAws_restJson1UpdateEventSourcesConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2694,8 +2721,7 @@ const deserializeAws_restJson1UpdateResourceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2714,10 +2740,12 @@ const deserializeAws_restJson1UpdateResourceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2746,8 +2774,7 @@ const deserializeAws_restJson1UpdateServiceIntegrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.devopsguru#AccessDeniedException": @@ -2766,10 +2793,12 @@ const deserializeAws_restJson1UpdateServiceIntegrationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4981,7 +5010,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5007,6 +5036,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-direct-connect/src/protocols/Aws_json1_1.ts b/clients/client-direct-connect/src/protocols/Aws_json1_1.ts index 929ebcc410d7f..7c7e2db72ff07 100644 --- a/clients/client-direct-connect/src/protocols/Aws_json1_1.ts +++ b/clients/client-direct-connect/src/protocols/Aws_json1_1.ts @@ -1194,8 +1194,7 @@ const deserializeAws_json1_1AcceptDirectConnectGatewayAssociationProposalCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1205,10 +1204,12 @@ const deserializeAws_json1_1AcceptDirectConnectGatewayAssociationProposalCommand throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1240,8 +1241,7 @@ const deserializeAws_json1_1AllocateConnectionOnInterconnectCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1251,10 +1251,12 @@ const deserializeAws_json1_1AllocateConnectionOnInterconnectCommandError = async throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1286,8 +1288,7 @@ const deserializeAws_json1_1AllocateHostedConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1303,10 +1304,12 @@ const deserializeAws_json1_1AllocateHostedConnectionCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1338,8 +1341,7 @@ const deserializeAws_json1_1AllocatePrivateVirtualInterfaceCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1355,10 +1357,12 @@ const deserializeAws_json1_1AllocatePrivateVirtualInterfaceCommandError = async throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1390,8 +1394,7 @@ const deserializeAws_json1_1AllocatePublicVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1407,10 +1410,12 @@ const deserializeAws_json1_1AllocatePublicVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1442,8 +1447,7 @@ const deserializeAws_json1_1AllocateTransitVirtualInterfaceCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1459,10 +1463,12 @@ const deserializeAws_json1_1AllocateTransitVirtualInterfaceCommandError = async throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1494,8 +1500,7 @@ const deserializeAws_json1_1AssociateConnectionWithLagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1505,10 +1510,12 @@ const deserializeAws_json1_1AssociateConnectionWithLagCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1540,8 +1547,7 @@ const deserializeAws_json1_1AssociateHostedConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1551,10 +1557,12 @@ const deserializeAws_json1_1AssociateHostedConnectionCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1586,8 +1594,7 @@ const deserializeAws_json1_1AssociateMacSecKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1597,10 +1604,12 @@ const deserializeAws_json1_1AssociateMacSecKeyCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1632,8 +1641,7 @@ const deserializeAws_json1_1AssociateVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1643,10 +1651,12 @@ const deserializeAws_json1_1AssociateVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1678,8 +1688,7 @@ const deserializeAws_json1_1ConfirmConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1689,10 +1698,12 @@ const deserializeAws_json1_1ConfirmConnectionCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1724,8 +1735,7 @@ const deserializeAws_json1_1ConfirmCustomerAgreementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1735,10 +1745,12 @@ const deserializeAws_json1_1ConfirmCustomerAgreementCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1770,8 +1782,7 @@ const deserializeAws_json1_1ConfirmPrivateVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1781,10 +1792,12 @@ const deserializeAws_json1_1ConfirmPrivateVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1816,8 +1829,7 @@ const deserializeAws_json1_1ConfirmPublicVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1827,10 +1839,12 @@ const deserializeAws_json1_1ConfirmPublicVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1862,8 +1876,7 @@ const deserializeAws_json1_1ConfirmTransitVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1873,10 +1886,12 @@ const deserializeAws_json1_1ConfirmTransitVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1908,8 +1923,7 @@ const deserializeAws_json1_1CreateBGPPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1919,10 +1933,12 @@ const deserializeAws_json1_1CreateBGPPeerCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1954,8 +1970,7 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -1971,10 +1986,12 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2006,8 +2023,7 @@ const deserializeAws_json1_1CreateDirectConnectGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2017,10 +2033,12 @@ const deserializeAws_json1_1CreateDirectConnectGatewayCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2052,8 +2070,7 @@ const deserializeAws_json1_1CreateDirectConnectGatewayAssociationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2063,10 +2080,12 @@ const deserializeAws_json1_1CreateDirectConnectGatewayAssociationCommandError = throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2098,8 +2117,7 @@ const deserializeAws_json1_1CreateDirectConnectGatewayAssociationProposalCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2109,10 +2127,12 @@ const deserializeAws_json1_1CreateDirectConnectGatewayAssociationProposalCommand throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2144,8 +2164,7 @@ const deserializeAws_json1_1CreateInterconnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2161,10 +2180,12 @@ const deserializeAws_json1_1CreateInterconnectCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2196,8 +2217,7 @@ const deserializeAws_json1_1CreateLagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2213,10 +2233,12 @@ const deserializeAws_json1_1CreateLagCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2248,8 +2270,7 @@ const deserializeAws_json1_1CreatePrivateVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2265,10 +2286,12 @@ const deserializeAws_json1_1CreatePrivateVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2300,8 +2323,7 @@ const deserializeAws_json1_1CreatePublicVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2317,10 +2339,12 @@ const deserializeAws_json1_1CreatePublicVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2352,8 +2376,7 @@ const deserializeAws_json1_1CreateTransitVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2369,10 +2392,12 @@ const deserializeAws_json1_1CreateTransitVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2404,8 +2429,7 @@ const deserializeAws_json1_1DeleteBGPPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2415,10 +2439,12 @@ const deserializeAws_json1_1DeleteBGPPeerCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2450,8 +2476,7 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2461,10 +2486,12 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2496,8 +2523,7 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2507,10 +2533,12 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2542,8 +2570,7 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayAssociationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2553,10 +2580,12 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayAssociationCommandError = throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2588,8 +2617,7 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayAssociationProposalCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2599,10 +2627,12 @@ const deserializeAws_json1_1DeleteDirectConnectGatewayAssociationProposalCommand throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2634,8 +2664,7 @@ const deserializeAws_json1_1DeleteInterconnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2645,10 +2674,12 @@ const deserializeAws_json1_1DeleteInterconnectCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2680,8 +2711,7 @@ const deserializeAws_json1_1DeleteLagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2691,10 +2721,12 @@ const deserializeAws_json1_1DeleteLagCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2726,8 +2758,7 @@ const deserializeAws_json1_1DeleteVirtualInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2737,10 +2768,12 @@ const deserializeAws_json1_1DeleteVirtualInterfaceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2772,8 +2805,7 @@ const deserializeAws_json1_1DescribeConnectionLoaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2783,10 +2815,12 @@ const deserializeAws_json1_1DescribeConnectionLoaCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2818,8 +2852,7 @@ const deserializeAws_json1_1DescribeConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2829,10 +2862,12 @@ const deserializeAws_json1_1DescribeConnectionsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2864,8 +2899,7 @@ const deserializeAws_json1_1DescribeConnectionsOnInterconnectCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2875,10 +2909,12 @@ const deserializeAws_json1_1DescribeConnectionsOnInterconnectCommandError = asyn throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2910,8 +2946,7 @@ const deserializeAws_json1_1DescribeCustomerMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2921,10 +2956,12 @@ const deserializeAws_json1_1DescribeCustomerMetadataCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2956,8 +2993,7 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAssociationProposalsComm body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -2967,10 +3003,12 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAssociationProposalsComm throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3002,8 +3040,7 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAssociationsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3013,10 +3050,12 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAssociationsCommandError throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3048,8 +3087,7 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAttachmentsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3059,10 +3097,12 @@ const deserializeAws_json1_1DescribeDirectConnectGatewayAttachmentsCommandError throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3094,8 +3134,7 @@ const deserializeAws_json1_1DescribeDirectConnectGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3105,10 +3144,12 @@ const deserializeAws_json1_1DescribeDirectConnectGatewaysCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3140,8 +3181,7 @@ const deserializeAws_json1_1DescribeHostedConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3151,10 +3191,12 @@ const deserializeAws_json1_1DescribeHostedConnectionsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3186,8 +3228,7 @@ const deserializeAws_json1_1DescribeInterconnectLoaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3197,10 +3238,12 @@ const deserializeAws_json1_1DescribeInterconnectLoaCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3232,8 +3275,7 @@ const deserializeAws_json1_1DescribeInterconnectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3243,10 +3285,12 @@ const deserializeAws_json1_1DescribeInterconnectsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3278,8 +3322,7 @@ const deserializeAws_json1_1DescribeLagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3289,10 +3332,12 @@ const deserializeAws_json1_1DescribeLagsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3324,8 +3369,7 @@ const deserializeAws_json1_1DescribeLoaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3335,10 +3379,12 @@ const deserializeAws_json1_1DescribeLoaCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3370,8 +3416,7 @@ const deserializeAws_json1_1DescribeLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3381,10 +3426,12 @@ const deserializeAws_json1_1DescribeLocationsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3416,8 +3463,7 @@ const deserializeAws_json1_1DescribeRouterConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3427,10 +3473,12 @@ const deserializeAws_json1_1DescribeRouterConfigurationCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3462,8 +3510,7 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3473,10 +3520,12 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3508,8 +3557,7 @@ const deserializeAws_json1_1DescribeVirtualGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3519,10 +3567,12 @@ const deserializeAws_json1_1DescribeVirtualGatewaysCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3554,8 +3604,7 @@ const deserializeAws_json1_1DescribeVirtualInterfacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3565,10 +3614,12 @@ const deserializeAws_json1_1DescribeVirtualInterfacesCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3600,8 +3651,7 @@ const deserializeAws_json1_1DisassociateConnectionFromLagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3611,10 +3661,12 @@ const deserializeAws_json1_1DisassociateConnectionFromLagCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3646,8 +3698,7 @@ const deserializeAws_json1_1DisassociateMacSecKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3657,10 +3708,12 @@ const deserializeAws_json1_1DisassociateMacSecKeyCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3692,8 +3745,7 @@ const deserializeAws_json1_1ListVirtualInterfaceTestHistoryCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3703,10 +3755,12 @@ const deserializeAws_json1_1ListVirtualInterfaceTestHistoryCommandError = async throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3738,8 +3792,7 @@ const deserializeAws_json1_1StartBgpFailoverTestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3749,10 +3802,12 @@ const deserializeAws_json1_1StartBgpFailoverTestCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3784,8 +3839,7 @@ const deserializeAws_json1_1StopBgpFailoverTestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3795,10 +3849,12 @@ const deserializeAws_json1_1StopBgpFailoverTestCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3830,8 +3886,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3847,10 +3902,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3882,8 +3939,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3893,10 +3949,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3928,8 +3986,7 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3939,10 +3996,12 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3974,8 +4033,7 @@ const deserializeAws_json1_1UpdateDirectConnectGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -3985,10 +4043,12 @@ const deserializeAws_json1_1UpdateDirectConnectGatewayCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4020,8 +4080,7 @@ const deserializeAws_json1_1UpdateDirectConnectGatewayAssociationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -4031,10 +4090,12 @@ const deserializeAws_json1_1UpdateDirectConnectGatewayAssociationCommandError = throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4066,8 +4127,7 @@ const deserializeAws_json1_1UpdateLagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -4077,10 +4137,12 @@ const deserializeAws_json1_1UpdateLagCommandError = async ( throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4112,8 +4174,7 @@ const deserializeAws_json1_1UpdateVirtualInterfaceAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectConnectClientException": case "com.amazonaws.directconnect#DirectConnectClientException": @@ -4123,10 +4184,12 @@ const deserializeAws_json1_1UpdateVirtualInterfaceAttributesCommandError = async throw await deserializeAws_json1_1DirectConnectServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6308,7 +6371,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6334,6 +6397,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-directory-service/src/protocols/Aws_json1_1.ts b/clients/client-directory-service/src/protocols/Aws_json1_1.ts index b4b87277e1430..b513c4978150e 100644 --- a/clients/client-directory-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-directory-service/src/protocols/Aws_json1_1.ts @@ -1240,8 +1240,7 @@ const deserializeAws_json1_1AcceptSharedDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1260,10 +1259,12 @@ const deserializeAws_json1_1AcceptSharedDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1295,8 +1296,7 @@ const deserializeAws_json1_1AddIpRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1321,10 +1321,12 @@ const deserializeAws_json1_1AddIpRoutesCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1356,8 +1358,7 @@ const deserializeAws_json1_1AddRegionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -1391,10 +1392,12 @@ const deserializeAws_json1_1AddRegionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1426,8 +1429,7 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1446,10 +1448,12 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( throw await deserializeAws_json1_1TagLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1481,8 +1485,7 @@ const deserializeAws_json1_1CancelSchemaExtensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1495,10 +1498,12 @@ const deserializeAws_json1_1CancelSchemaExtensionCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1530,8 +1535,7 @@ const deserializeAws_json1_1ConnectDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1547,10 +1551,12 @@ const deserializeAws_json1_1ConnectDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1588,7 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1602,10 +1607,12 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1637,8 +1644,7 @@ const deserializeAws_json1_1CreateComputerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationFailedException": case "com.amazonaws.directoryservice#AuthenticationFailedException": @@ -1666,10 +1672,12 @@ const deserializeAws_json1_1CreateComputerCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1701,8 +1709,7 @@ const deserializeAws_json1_1CreateConditionalForwarderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1727,10 +1734,12 @@ const deserializeAws_json1_1CreateConditionalForwarderCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1762,8 +1771,7 @@ const deserializeAws_json1_1CreateDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1779,10 +1787,12 @@ const deserializeAws_json1_1CreateDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1824,7 @@ const deserializeAws_json1_1CreateLogSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1837,10 +1846,12 @@ const deserializeAws_json1_1CreateLogSubscriptionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1872,8 +1883,7 @@ const deserializeAws_json1_1CreateMicrosoftADCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1892,10 +1902,12 @@ const deserializeAws_json1_1CreateMicrosoftADCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1927,8 +1939,7 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -1947,10 +1958,12 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( throw await deserializeAws_json1_1SnapshotLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1982,8 +1995,7 @@ const deserializeAws_json1_1CreateTrustCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2005,10 +2017,12 @@ const deserializeAws_json1_1CreateTrustCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2040,8 +2054,7 @@ const deserializeAws_json1_1DeleteConditionalForwarderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2063,10 +2076,12 @@ const deserializeAws_json1_1DeleteConditionalForwarderCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2098,8 +2113,7 @@ const deserializeAws_json1_1DeleteDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2112,10 +2126,12 @@ const deserializeAws_json1_1DeleteDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2147,8 +2163,7 @@ const deserializeAws_json1_1DeleteLogSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2164,10 +2179,12 @@ const deserializeAws_json1_1DeleteLogSubscriptionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2199,8 +2216,7 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2216,10 +2232,12 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2269,7 @@ const deserializeAws_json1_1DeleteTrustCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2271,10 +2288,12 @@ const deserializeAws_json1_1DeleteTrustCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2306,8 +2325,7 @@ const deserializeAws_json1_1DeregisterCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateDoesNotExistException": case "com.amazonaws.directoryservice#CertificateDoesNotExistException": @@ -2335,10 +2353,12 @@ const deserializeAws_json1_1DeregisterCertificateCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2370,8 +2390,7 @@ const deserializeAws_json1_1DeregisterEventTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2387,10 +2406,12 @@ const deserializeAws_json1_1DeregisterEventTopicCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2422,8 +2443,7 @@ const deserializeAws_json1_1DescribeCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateDoesNotExistException": case "com.amazonaws.directoryservice#CertificateDoesNotExistException": @@ -2445,10 +2465,12 @@ const deserializeAws_json1_1DescribeCertificateCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2502,7 @@ const deserializeAws_json1_1DescribeClientAuthenticationSettingsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -2503,10 +2524,12 @@ const deserializeAws_json1_1DescribeClientAuthenticationSettingsCommandError = a throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2538,8 +2561,7 @@ const deserializeAws_json1_1DescribeConditionalForwardersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2561,10 +2583,12 @@ const deserializeAws_json1_1DescribeConditionalForwardersCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2596,8 +2620,7 @@ const deserializeAws_json1_1DescribeDirectoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2616,10 +2639,12 @@ const deserializeAws_json1_1DescribeDirectoriesCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2651,8 +2676,7 @@ const deserializeAws_json1_1DescribeDomainControllersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2674,10 +2698,12 @@ const deserializeAws_json1_1DescribeDomainControllersCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2709,8 +2735,7 @@ const deserializeAws_json1_1DescribeEventTopicsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2726,10 +2751,12 @@ const deserializeAws_json1_1DescribeEventTopicsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2761,8 +2788,7 @@ const deserializeAws_json1_1DescribeLDAPSSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2784,10 +2810,12 @@ const deserializeAws_json1_1DescribeLDAPSSettingsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2819,8 +2847,7 @@ const deserializeAws_json1_1DescribeRegionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -2845,10 +2872,12 @@ const deserializeAws_json1_1DescribeRegionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2880,8 +2909,7 @@ const deserializeAws_json1_1DescribeSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2903,10 +2931,12 @@ const deserializeAws_json1_1DescribeSettingsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2938,8 +2968,7 @@ const deserializeAws_json1_1DescribeSharedDirectoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -2961,10 +2990,12 @@ const deserializeAws_json1_1DescribeSharedDirectoriesCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2996,8 +3027,7 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3016,10 +3046,12 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3051,8 +3083,7 @@ const deserializeAws_json1_1DescribeTrustsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3074,10 +3105,12 @@ const deserializeAws_json1_1DescribeTrustsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3109,8 +3142,7 @@ const deserializeAws_json1_1DisableClientAuthenticationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -3132,10 +3164,12 @@ const deserializeAws_json1_1DisableClientAuthenticationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3167,8 +3201,7 @@ const deserializeAws_json1_1DisableLDAPSCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3193,10 +3226,12 @@ const deserializeAws_json1_1DisableLDAPSCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3228,8 +3263,7 @@ const deserializeAws_json1_1DisableRadiusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3242,10 +3276,12 @@ const deserializeAws_json1_1DisableRadiusCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3277,8 +3313,7 @@ const deserializeAws_json1_1DisableSsoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationFailedException": case "com.amazonaws.directoryservice#AuthenticationFailedException": @@ -3297,10 +3332,12 @@ const deserializeAws_json1_1DisableSsoCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3332,8 +3369,7 @@ const deserializeAws_json1_1EnableClientAuthenticationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -3358,10 +3394,12 @@ const deserializeAws_json1_1EnableClientAuthenticationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3393,8 +3431,7 @@ const deserializeAws_json1_1EnableLDAPSCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3422,10 +3459,12 @@ const deserializeAws_json1_1EnableLDAPSCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3457,8 +3496,7 @@ const deserializeAws_json1_1EnableRadiusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3477,10 +3515,12 @@ const deserializeAws_json1_1EnableRadiusCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3512,8 +3552,7 @@ const deserializeAws_json1_1EnableSsoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationFailedException": case "com.amazonaws.directoryservice#AuthenticationFailedException": @@ -3532,10 +3571,12 @@ const deserializeAws_json1_1EnableSsoCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3567,8 +3608,7 @@ const deserializeAws_json1_1GetDirectoryLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3581,10 +3621,12 @@ const deserializeAws_json1_1GetDirectoryLimitsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3616,8 +3658,7 @@ const deserializeAws_json1_1GetSnapshotLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3630,10 +3671,12 @@ const deserializeAws_json1_1GetSnapshotLimitsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3665,8 +3708,7 @@ const deserializeAws_json1_1ListCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3688,10 +3730,12 @@ const deserializeAws_json1_1ListCertificatesCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3723,8 +3767,7 @@ const deserializeAws_json1_1ListIpRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3743,10 +3786,12 @@ const deserializeAws_json1_1ListIpRoutesCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3778,8 +3823,7 @@ const deserializeAws_json1_1ListLogSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3795,10 +3839,12 @@ const deserializeAws_json1_1ListLogSubscriptionsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3830,8 +3876,7 @@ const deserializeAws_json1_1ListSchemaExtensionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3847,10 +3892,12 @@ const deserializeAws_json1_1ListSchemaExtensionsCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3882,8 +3929,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -3902,10 +3948,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3937,8 +3985,7 @@ const deserializeAws_json1_1RegisterCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateAlreadyExistsException": case "com.amazonaws.directoryservice#CertificateAlreadyExistsException": @@ -3969,10 +4016,12 @@ const deserializeAws_json1_1RegisterCertificateCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4004,8 +4053,7 @@ const deserializeAws_json1_1RegisterEventTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4021,10 +4069,12 @@ const deserializeAws_json1_1RegisterEventTopicCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4056,8 +4106,7 @@ const deserializeAws_json1_1RejectSharedDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4076,10 +4125,12 @@ const deserializeAws_json1_1RejectSharedDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4111,8 +4162,7 @@ const deserializeAws_json1_1RemoveIpRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4131,10 +4181,12 @@ const deserializeAws_json1_1RemoveIpRoutesCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4166,8 +4218,7 @@ const deserializeAws_json1_1RemoveRegionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -4189,10 +4240,12 @@ const deserializeAws_json1_1RemoveRegionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4224,8 +4277,7 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4241,10 +4293,12 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4276,8 +4330,7 @@ const deserializeAws_json1_1ResetUserPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4302,10 +4355,12 @@ const deserializeAws_json1_1ResetUserPasswordCommandError = async ( throw await deserializeAws_json1_1UserDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4337,8 +4392,7 @@ const deserializeAws_json1_1RestoreFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4354,10 +4408,12 @@ const deserializeAws_json1_1RestoreFromSnapshotCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4389,8 +4445,7 @@ const deserializeAws_json1_1ShareDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.directoryservice#AccessDeniedException": @@ -4424,10 +4479,12 @@ const deserializeAws_json1_1ShareDirectoryCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4459,8 +4516,7 @@ const deserializeAws_json1_1StartSchemaExtensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4482,10 +4538,12 @@ const deserializeAws_json1_1StartSchemaExtensionCommandError = async ( throw await deserializeAws_json1_1SnapshotLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4517,8 +4575,7 @@ const deserializeAws_json1_1UnshareDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4537,10 +4594,12 @@ const deserializeAws_json1_1UnshareDirectoryCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4572,8 +4631,7 @@ const deserializeAws_json1_1UpdateConditionalForwarderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4595,10 +4653,12 @@ const deserializeAws_json1_1UpdateConditionalForwarderCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4630,8 +4690,7 @@ const deserializeAws_json1_1UpdateNumberOfDomainControllersCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4656,10 +4715,12 @@ const deserializeAws_json1_1UpdateNumberOfDomainControllersCommandError = async throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4691,8 +4752,7 @@ const deserializeAws_json1_1UpdateRadiusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4708,10 +4768,12 @@ const deserializeAws_json1_1UpdateRadiusCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4743,8 +4805,7 @@ const deserializeAws_json1_1UpdateSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4772,10 +4833,12 @@ const deserializeAws_json1_1UpdateSettingsCommandError = async ( throw await deserializeAws_json1_1UnsupportedSettingsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4807,8 +4870,7 @@ const deserializeAws_json1_1UpdateTrustCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4824,10 +4886,12 @@ const deserializeAws_json1_1UpdateTrustCommandError = async ( throw await deserializeAws_json1_1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4859,8 +4923,7 @@ const deserializeAws_json1_1VerifyTrustCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.directoryservice#ClientException": @@ -4879,10 +4942,12 @@ const deserializeAws_json1_1VerifyTrustCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7968,7 +8033,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7994,6 +8059,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-dlm/src/protocols/Aws_restJson1.ts b/clients/client-dlm/src/protocols/Aws_restJson1.ts index 13db4d68dcc2a..6c6aadd63488c 100644 --- a/clients/client-dlm/src/protocols/Aws_restJson1.ts +++ b/clients/client-dlm/src/protocols/Aws_restJson1.ts @@ -346,8 +346,7 @@ const deserializeAws_restJson1CreateLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -360,10 +359,12 @@ const deserializeAws_restJson1CreateLifecyclePolicyCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -392,8 +393,7 @@ const deserializeAws_restJson1DeleteLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -406,10 +406,12 @@ const deserializeAws_restJson1DeleteLifecyclePolicyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -442,8 +444,7 @@ const deserializeAws_restJson1GetLifecyclePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -459,10 +460,12 @@ const deserializeAws_restJson1GetLifecyclePoliciesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -495,8 +498,7 @@ const deserializeAws_restJson1GetLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -509,10 +511,12 @@ const deserializeAws_restJson1GetLifecyclePolicyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -545,8 +549,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -559,10 +562,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -591,8 +596,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -605,10 +609,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -637,8 +643,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -651,10 +656,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -683,8 +690,7 @@ const deserializeAws_restJson1UpdateLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.dlm#InternalServerException": @@ -700,10 +706,12 @@ const deserializeAws_restJson1UpdateLifecyclePolicyCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1733,7 +1741,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1759,6 +1767,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-docdb/src/protocols/Aws_query.ts b/clients/client-docdb/src/protocols/Aws_query.ts index f8272aecdd684..4583ca7d61601 100644 --- a/clients/client-docdb/src/protocols/Aws_query.ts +++ b/clients/client-docdb/src/protocols/Aws_query.ts @@ -1264,8 +1264,7 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.docdb#SourceNotFoundFault": @@ -1275,10 +1274,12 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1307,8 +1308,7 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -1321,10 +1321,12 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1356,8 +1358,7 @@ const deserializeAws_queryApplyPendingMaintenanceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDBClusterStateFault": case "com.amazonaws.docdb#InvalidDBClusterStateFault": @@ -1370,10 +1371,12 @@ const deserializeAws_queryApplyPendingMaintenanceActionCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1405,8 +1408,7 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.docdb#DBParameterGroupAlreadyExistsFault": @@ -1419,10 +1421,12 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1454,8 +1458,7 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotAlreadyExistsFault": case "com.amazonaws.docdb#DBClusterSnapshotAlreadyExistsFault": @@ -1477,10 +1480,12 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1512,8 +1517,7 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.docdb#DBClusterAlreadyExistsFault": @@ -1568,10 +1572,12 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1603,8 +1609,7 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.docdb#DBParameterGroupAlreadyExistsFault": @@ -1614,10 +1619,12 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1649,8 +1656,7 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -1669,10 +1675,12 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1704,8 +1712,7 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.docdb#AuthorizationNotFoundFault": @@ -1754,10 +1761,12 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1789,8 +1798,7 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupAlreadyExistsFault": case "com.amazonaws.docdb#DBSubnetGroupAlreadyExistsFault": @@ -1809,10 +1817,12 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidSubnetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1844,8 +1854,7 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.docdb#EventSubscriptionQuotaExceededFault": @@ -1870,10 +1879,12 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionCategoryNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1905,8 +1916,7 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -1922,10 +1932,12 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1957,8 +1969,7 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -1977,10 +1988,12 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2009,8 +2022,7 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.docdb#DBParameterGroupNotFoundFault": @@ -2020,10 +2032,12 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2055,8 +2069,7 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.docdb#DBClusterSnapshotNotFoundFault": @@ -2066,10 +2079,12 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidDBClusterSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2101,8 +2116,7 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.docdb#DBInstanceNotFoundFault": @@ -2121,10 +2135,12 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2153,8 +2169,7 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.docdb#DBSubnetGroupNotFoundFault": @@ -2167,10 +2182,12 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidDBSubnetStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2202,8 +2219,7 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEventSubscriptionStateFault": case "com.amazonaws.docdb#InvalidEventSubscriptionStateFault": @@ -2213,10 +2229,12 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2248,8 +2266,7 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.docdb#GlobalClusterNotFoundFault": @@ -2259,10 +2276,12 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2294,18 +2313,19 @@ const deserializeAws_queryDescribeCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateNotFoundFault": case "com.amazonaws.docdb#CertificateNotFoundFault": throw await deserializeAws_queryCertificateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2337,18 +2357,19 @@ const deserializeAws_queryDescribeDBClusterParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.docdb#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2380,18 +2401,19 @@ const deserializeAws_queryDescribeDBClusterParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.docdb#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2423,18 +2445,19 @@ const deserializeAws_queryDescribeDBClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2469,18 +2492,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotAttributesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.docdb#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2512,18 +2536,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.docdb#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2555,15 +2580,16 @@ const deserializeAws_queryDescribeDBEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2595,18 +2621,19 @@ const deserializeAws_queryDescribeDBInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.docdb#DBInstanceNotFoundFault": throw await deserializeAws_queryDBInstanceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2638,18 +2665,19 @@ const deserializeAws_queryDescribeDBSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.docdb#DBSubnetGroupNotFoundFault": throw await deserializeAws_queryDBSubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2684,15 +2712,16 @@ const deserializeAws_queryDescribeEngineDefaultClusterParametersCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2724,15 +2753,16 @@ const deserializeAws_queryDescribeEventCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2764,15 +2794,16 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2804,18 +2835,19 @@ const deserializeAws_queryDescribeEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SubscriptionNotFoundFault": case "com.amazonaws.docdb#SubscriptionNotFoundFault": throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2847,18 +2879,19 @@ const deserializeAws_queryDescribeGlobalClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.docdb#GlobalClusterNotFoundFault": throw await deserializeAws_queryGlobalClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2893,15 +2926,16 @@ const deserializeAws_queryDescribeOrderableDBInstanceOptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2936,18 +2970,19 @@ const deserializeAws_queryDescribePendingMaintenanceActionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.docdb#ResourceNotFoundFault": throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2979,8 +3014,7 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -2993,10 +3027,12 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3028,8 +3064,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -3042,10 +3077,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3077,8 +3114,7 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.docdb#DBClusterAlreadyExistsFault": @@ -3115,10 +3151,12 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3150,8 +3188,7 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.docdb#DBParameterGroupNotFoundFault": @@ -3161,10 +3198,12 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3199,8 +3238,7 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.docdb#DBClusterSnapshotNotFoundFault": @@ -3213,10 +3251,12 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( throw await deserializeAws_querySharedSnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3248,8 +3288,7 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.docdb#AuthorizationNotFoundFault": @@ -3292,10 +3331,12 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3327,8 +3368,7 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupDoesNotCoverEnoughAZs": case "com.amazonaws.docdb#DBSubnetGroupDoesNotCoverEnoughAZs": @@ -3347,10 +3387,12 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( throw await deserializeAws_querySubnetAlreadyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3382,8 +3424,7 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.docdb#EventSubscriptionQuotaExceededFault": @@ -3405,10 +3446,12 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3440,8 +3483,7 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.docdb#GlobalClusterNotFoundFault": @@ -3451,10 +3493,12 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3486,8 +3530,7 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.docdb#DBInstanceNotFoundFault": @@ -3497,10 +3540,12 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3532,8 +3577,7 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -3546,10 +3590,12 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3584,8 +3630,7 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.docdb#SourceNotFoundFault": @@ -3595,10 +3640,12 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3627,8 +3674,7 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -3641,10 +3687,12 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3676,8 +3724,7 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.docdb#DBParameterGroupNotFoundFault": @@ -3687,10 +3734,12 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3722,8 +3771,7 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.docdb#DBClusterAlreadyExistsFault": @@ -3769,10 +3817,12 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3804,8 +3854,7 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.docdb#DBClusterAlreadyExistsFault": @@ -3854,10 +3903,12 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3889,8 +3940,7 @@ const deserializeAws_queryStartDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -3903,10 +3953,12 @@ const deserializeAws_queryStartDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3938,8 +3990,7 @@ const deserializeAws_queryStopDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.docdb#DBClusterNotFoundFault": @@ -3952,10 +4003,12 @@ const deserializeAws_queryStopDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9313,12 +9366,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-drs/src/protocols/Aws_restJson1.ts b/clients/client-drs/src/protocols/Aws_restJson1.ts index 0a5c1b3a3c31f..ed87368800f90 100644 --- a/clients/client-drs/src/protocols/Aws_restJson1.ts +++ b/clients/client-drs/src/protocols/Aws_restJson1.ts @@ -1221,8 +1221,7 @@ const deserializeAws_restJson1CreateExtendedSourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1247,10 +1246,12 @@ const deserializeAws_restJson1CreateExtendedSourceServerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1346,8 +1347,7 @@ const deserializeAws_restJson1CreateReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1369,10 +1369,12 @@ const deserializeAws_restJson1CreateReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1401,8 +1403,7 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -1421,10 +1422,12 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,8 +1456,7 @@ const deserializeAws_restJson1DeleteRecoveryInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1473,10 +1475,12 @@ const deserializeAws_restJson1DeleteRecoveryInstanceCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1505,8 +1509,7 @@ const deserializeAws_restJson1DeleteReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -1525,10 +1528,12 @@ const deserializeAws_restJson1DeleteReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1557,8 +1562,7 @@ const deserializeAws_restJson1DeleteSourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -1577,10 +1581,12 @@ const deserializeAws_restJson1DeleteSourceServerCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1617,8 +1623,7 @@ const deserializeAws_restJson1DescribeJobLogItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -1634,10 +1639,12 @@ const deserializeAws_restJson1DescribeJobLogItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1674,8 +1681,7 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -1691,10 +1697,12 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1731,8 +1739,7 @@ const deserializeAws_restJson1DescribeRecoveryInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1748,10 +1755,12 @@ const deserializeAws_restJson1DescribeRecoveryInstancesCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1788,8 +1797,7 @@ const deserializeAws_restJson1DescribeRecoverySnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1808,10 +1816,12 @@ const deserializeAws_restJson1DescribeRecoverySnapshotsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1848,8 +1858,7 @@ const deserializeAws_restJson1DescribeReplicationConfigurationTemplatesCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -1868,10 +1877,12 @@ const deserializeAws_restJson1DescribeReplicationConfigurationTemplatesCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1908,8 +1919,7 @@ const deserializeAws_restJson1DescribeSourceServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -1925,10 +1935,12 @@ const deserializeAws_restJson1DescribeSourceServersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1957,8 +1969,7 @@ const deserializeAws_restJson1DisconnectRecoveryInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -1980,10 +1991,12 @@ const deserializeAws_restJson1DisconnectRecoveryInstanceCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2048,8 +2061,7 @@ const deserializeAws_restJson1DisconnectSourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -2068,10 +2080,12 @@ const deserializeAws_restJson1DisconnectSourceServerCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2116,8 +2130,7 @@ const deserializeAws_restJson1GetFailbackReplicationConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -2133,10 +2146,12 @@ const deserializeAws_restJson1GetFailbackReplicationConfigurationCommandError = throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2197,8 +2212,7 @@ const deserializeAws_restJson1GetLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -2214,10 +2228,12 @@ const deserializeAws_restJson1GetLaunchConfigurationCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2316,8 +2332,7 @@ const deserializeAws_restJson1GetReplicationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2336,10 +2351,12 @@ const deserializeAws_restJson1GetReplicationConfigurationCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2368,8 +2385,7 @@ const deserializeAws_restJson1InitializeServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2385,10 +2401,12 @@ const deserializeAws_restJson1InitializeServiceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2425,8 +2443,7 @@ const deserializeAws_restJson1ListExtensibleSourceServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2445,10 +2462,12 @@ const deserializeAws_restJson1ListExtensibleSourceServersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2485,8 +2504,7 @@ const deserializeAws_restJson1ListStagingAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2505,10 +2523,12 @@ const deserializeAws_restJson1ListStagingAccountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2541,8 +2561,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2561,10 +2580,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2629,8 +2650,7 @@ const deserializeAws_restJson1RetryDataReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -2649,10 +2669,12 @@ const deserializeAws_restJson1RetryDataReplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2685,8 +2707,7 @@ const deserializeAws_restJson1StartFailbackLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -2708,10 +2729,12 @@ const deserializeAws_restJson1StartFailbackLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2744,8 +2767,7 @@ const deserializeAws_restJson1StartRecoveryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -2764,10 +2786,12 @@ const deserializeAws_restJson1StartRecoveryCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2796,8 +2820,7 @@ const deserializeAws_restJson1StopFailbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.drs#InternalServerException": @@ -2813,10 +2836,12 @@ const deserializeAws_restJson1StopFailbackCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2845,8 +2870,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2865,10 +2889,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2901,8 +2927,7 @@ const deserializeAws_restJson1TerminateRecoveryInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -2921,10 +2946,12 @@ const deserializeAws_restJson1TerminateRecoveryInstancesCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2980,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -2973,10 +2999,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3005,8 +3033,7 @@ const deserializeAws_restJson1UpdateFailbackReplicationConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -3025,10 +3052,12 @@ const deserializeAws_restJson1UpdateFailbackReplicationConfigurationCommandError throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3089,8 +3118,7 @@ const deserializeAws_restJson1UpdateLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.drs#ConflictException": @@ -3112,10 +3140,12 @@ const deserializeAws_restJson1UpdateLaunchConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3214,8 +3244,7 @@ const deserializeAws_restJson1UpdateReplicationConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -3240,10 +3269,12 @@ const deserializeAws_restJson1UpdateReplicationConfigurationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3339,8 +3370,7 @@ const deserializeAws_restJson1UpdateReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.drs#AccessDeniedException": @@ -3362,10 +3392,12 @@ const deserializeAws_restJson1UpdateReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4741,7 +4773,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4767,6 +4799,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-dynamodb-streams/src/protocols/Aws_json1_0.ts b/clients/client-dynamodb-streams/src/protocols/Aws_json1_0.ts index 7e54c91ce61d5..7256a0239e888 100644 --- a/clients/client-dynamodb-streams/src/protocols/Aws_json1_0.ts +++ b/clients/client-dynamodb-streams/src/protocols/Aws_json1_0.ts @@ -125,8 +125,7 @@ const deserializeAws_json1_0DescribeStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodbstreams#InternalServerError": @@ -136,10 +135,12 @@ const deserializeAws_json1_0DescribeStreamCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -171,8 +172,7 @@ const deserializeAws_json1_0GetRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredIteratorException": case "com.amazonaws.dynamodbstreams#ExpiredIteratorException": @@ -191,10 +191,12 @@ const deserializeAws_json1_0GetRecordsCommandError = async ( throw await deserializeAws_json1_0TrimmedDataAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -226,8 +228,7 @@ const deserializeAws_json1_0GetShardIteratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodbstreams#InternalServerError": @@ -240,10 +241,12 @@ const deserializeAws_json1_0GetShardIteratorCommandError = async ( throw await deserializeAws_json1_0TrimmedDataAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -275,8 +278,7 @@ const deserializeAws_json1_0ListStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodbstreams#InternalServerError": @@ -286,10 +288,12 @@ const deserializeAws_json1_0ListStreamsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -799,7 +803,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -825,6 +829,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-dynamodb/src/protocols/Aws_json1_0.ts b/clients/client-dynamodb/src/protocols/Aws_json1_0.ts index 06c0c6c33d0a5..df6667e1d36e3 100644 --- a/clients/client-dynamodb/src/protocols/Aws_json1_0.ts +++ b/clients/client-dynamodb/src/protocols/Aws_json1_0.ts @@ -1023,8 +1023,7 @@ const deserializeAws_json1_0BatchExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1034,10 +1033,12 @@ const deserializeAws_json1_0BatchExecuteStatementCommandError = async ( throw await deserializeAws_json1_0RequestLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1069,8 +1070,7 @@ const deserializeAws_json1_0BatchGetItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1089,10 +1089,12 @@ const deserializeAws_json1_0BatchGetItemCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1124,8 +1126,7 @@ const deserializeAws_json1_0BatchWriteItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1147,10 +1148,12 @@ const deserializeAws_json1_0BatchWriteItemCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1185,7 @@ const deserializeAws_json1_0CreateBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupInUseException": case "com.amazonaws.dynamodb#BackupInUseException": @@ -1208,10 +1210,12 @@ const deserializeAws_json1_0CreateBackupCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1247,7 @@ const deserializeAws_json1_0CreateGlobalTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalTableAlreadyExistsException": case "com.amazonaws.dynamodb#GlobalTableAlreadyExistsException": @@ -1263,10 +1266,12 @@ const deserializeAws_json1_0CreateGlobalTableCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1298,8 +1303,7 @@ const deserializeAws_json1_0CreateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1315,10 +1319,12 @@ const deserializeAws_json1_0CreateTableCommandError = async ( throw await deserializeAws_json1_0ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1350,8 +1356,7 @@ const deserializeAws_json1_0DeleteBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupInUseException": case "com.amazonaws.dynamodb#BackupInUseException": @@ -1370,10 +1375,12 @@ const deserializeAws_json1_0DeleteBackupCommandError = async ( throw await deserializeAws_json1_0LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1405,8 +1412,7 @@ const deserializeAws_json1_0DeleteItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionalCheckFailedException": case "com.amazonaws.dynamodb#ConditionalCheckFailedException": @@ -1434,10 +1440,12 @@ const deserializeAws_json1_0DeleteItemCommandError = async ( throw await deserializeAws_json1_0TransactionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1469,8 +1477,7 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1489,10 +1496,12 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1524,8 +1533,7 @@ const deserializeAws_json1_0DescribeBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupNotFoundException": case "com.amazonaws.dynamodb#BackupNotFoundException": @@ -1538,10 +1546,12 @@ const deserializeAws_json1_0DescribeBackupCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1573,8 +1583,7 @@ const deserializeAws_json1_0DescribeContinuousBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1587,10 +1596,12 @@ const deserializeAws_json1_0DescribeContinuousBackupsCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1622,8 +1633,7 @@ const deserializeAws_json1_0DescribeContributorInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1633,10 +1643,12 @@ const deserializeAws_json1_0DescribeContributorInsightsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1668,15 +1680,16 @@ const deserializeAws_json1_0DescribeEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1708,8 +1721,7 @@ const deserializeAws_json1_0DescribeExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExportNotFoundException": case "com.amazonaws.dynamodb#ExportNotFoundException": @@ -1722,10 +1734,12 @@ const deserializeAws_json1_0DescribeExportCommandError = async ( throw await deserializeAws_json1_0LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1757,8 +1771,7 @@ const deserializeAws_json1_0DescribeGlobalTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalTableNotFoundException": case "com.amazonaws.dynamodb#GlobalTableNotFoundException": @@ -1771,10 +1784,12 @@ const deserializeAws_json1_0DescribeGlobalTableCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1806,8 +1821,7 @@ const deserializeAws_json1_0DescribeGlobalTableSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalTableNotFoundException": case "com.amazonaws.dynamodb#GlobalTableNotFoundException": @@ -1820,10 +1834,12 @@ const deserializeAws_json1_0DescribeGlobalTableSettingsCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1855,8 +1871,7 @@ const deserializeAws_json1_0DescribeKinesisStreamingDestinationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1869,10 +1884,12 @@ const deserializeAws_json1_0DescribeKinesisStreamingDestinationCommandError = as throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1904,8 +1921,7 @@ const deserializeAws_json1_0DescribeLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1915,10 +1931,12 @@ const deserializeAws_json1_0DescribeLimitsCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1950,8 +1968,7 @@ const deserializeAws_json1_0DescribeTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -1964,10 +1981,12 @@ const deserializeAws_json1_0DescribeTableCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1999,8 +2018,7 @@ const deserializeAws_json1_0DescribeTableReplicaAutoScalingCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2010,10 +2028,12 @@ const deserializeAws_json1_0DescribeTableReplicaAutoScalingCommandError = async throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2065,7 @@ const deserializeAws_json1_0DescribeTimeToLiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2059,10 +2078,12 @@ const deserializeAws_json1_0DescribeTimeToLiveCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2094,8 +2115,7 @@ const deserializeAws_json1_0DisableKinesisStreamingDestinationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2114,10 +2134,12 @@ const deserializeAws_json1_0DisableKinesisStreamingDestinationCommandError = asy throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2149,8 +2171,7 @@ const deserializeAws_json1_0EnableKinesisStreamingDestinationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2169,10 +2190,12 @@ const deserializeAws_json1_0EnableKinesisStreamingDestinationCommandError = asyn throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2204,8 +2227,7 @@ const deserializeAws_json1_0ExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionalCheckFailedException": case "com.amazonaws.dynamodb#ConditionalCheckFailedException": @@ -2233,10 +2255,12 @@ const deserializeAws_json1_0ExecuteStatementCommandError = async ( throw await deserializeAws_json1_0TransactionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2268,8 +2292,7 @@ const deserializeAws_json1_0ExecuteTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.dynamodb#IdempotentParameterMismatchException": @@ -2294,10 +2317,12 @@ const deserializeAws_json1_0ExecuteTransactionCommandError = async ( throw await deserializeAws_json1_0TransactionInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2329,8 +2354,7 @@ const deserializeAws_json1_0ExportTableToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExportConflictException": case "com.amazonaws.dynamodb#ExportConflictException": @@ -2352,10 +2376,12 @@ const deserializeAws_json1_0ExportTableToPointInTimeCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2387,8 +2413,7 @@ const deserializeAws_json1_0GetItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2407,10 +2432,12 @@ const deserializeAws_json1_0GetItemCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2442,8 +2469,7 @@ const deserializeAws_json1_0ListBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2453,10 +2479,12 @@ const deserializeAws_json1_0ListBackupsCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2488,8 +2516,7 @@ const deserializeAws_json1_0ListContributorInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2499,10 +2526,12 @@ const deserializeAws_json1_0ListContributorInsightsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2534,8 +2563,7 @@ const deserializeAws_json1_0ListExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2545,10 +2573,12 @@ const deserializeAws_json1_0ListExportsCommandError = async ( throw await deserializeAws_json1_0LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2580,8 +2610,7 @@ const deserializeAws_json1_0ListGlobalTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2591,10 +2620,12 @@ const deserializeAws_json1_0ListGlobalTablesCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2626,8 +2657,7 @@ const deserializeAws_json1_0ListTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2637,10 +2667,12 @@ const deserializeAws_json1_0ListTablesCommandError = async ( throw await deserializeAws_json1_0InvalidEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2672,8 +2704,7 @@ const deserializeAws_json1_0ListTagsOfResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2686,10 +2717,12 @@ const deserializeAws_json1_0ListTagsOfResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2721,8 +2754,7 @@ const deserializeAws_json1_0PutItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionalCheckFailedException": case "com.amazonaws.dynamodb#ConditionalCheckFailedException": @@ -2750,10 +2782,12 @@ const deserializeAws_json1_0PutItemCommandError = async ( throw await deserializeAws_json1_0TransactionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2785,8 +2819,7 @@ const deserializeAws_json1_0QueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2805,10 +2838,12 @@ const deserializeAws_json1_0QueryCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2840,8 +2875,7 @@ const deserializeAws_json1_0RestoreTableFromBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupInUseException": case "com.amazonaws.dynamodb#BackupInUseException": @@ -2866,10 +2900,12 @@ const deserializeAws_json1_0RestoreTableFromBackupCommandError = async ( throw await deserializeAws_json1_0TableInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2901,8 +2937,7 @@ const deserializeAws_json1_0RestoreTableToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2930,10 +2965,12 @@ const deserializeAws_json1_0RestoreTableToPointInTimeCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2965,8 +3002,7 @@ const deserializeAws_json1_0ScanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -2985,10 +3021,12 @@ const deserializeAws_json1_0ScanCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3017,8 +3055,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3037,10 +3074,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3072,8 +3111,7 @@ const deserializeAws_json1_0TransactGetItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3095,10 +3133,12 @@ const deserializeAws_json1_0TransactGetItemsCommandError = async ( throw await deserializeAws_json1_0TransactionCanceledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3130,8 +3170,7 @@ const deserializeAws_json1_0TransactWriteItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.dynamodb#IdempotentParameterMismatchException": @@ -3159,10 +3198,12 @@ const deserializeAws_json1_0TransactWriteItemsCommandError = async ( throw await deserializeAws_json1_0TransactionInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3191,8 +3232,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3211,10 +3251,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3246,8 +3288,7 @@ const deserializeAws_json1_0UpdateContinuousBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContinuousBackupsUnavailableException": case "com.amazonaws.dynamodb#ContinuousBackupsUnavailableException": @@ -3263,10 +3304,12 @@ const deserializeAws_json1_0UpdateContinuousBackupsCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3298,8 +3341,7 @@ const deserializeAws_json1_0UpdateContributorInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3309,10 +3351,12 @@ const deserializeAws_json1_0UpdateContributorInsightsCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3344,8 +3388,7 @@ const deserializeAws_json1_0UpdateGlobalTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalTableNotFoundException": case "com.amazonaws.dynamodb#GlobalTableNotFoundException": @@ -3367,10 +3410,12 @@ const deserializeAws_json1_0UpdateGlobalTableCommandError = async ( throw await deserializeAws_json1_0TableNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3402,8 +3447,7 @@ const deserializeAws_json1_0UpdateGlobalTableSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalTableNotFoundException": case "com.amazonaws.dynamodb#GlobalTableNotFoundException": @@ -3428,10 +3472,12 @@ const deserializeAws_json1_0UpdateGlobalTableSettingsCommandError = async ( throw await deserializeAws_json1_0ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3463,8 +3509,7 @@ const deserializeAws_json1_0UpdateItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionalCheckFailedException": case "com.amazonaws.dynamodb#ConditionalCheckFailedException": @@ -3492,10 +3537,12 @@ const deserializeAws_json1_0UpdateItemCommandError = async ( throw await deserializeAws_json1_0TransactionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3527,8 +3574,7 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3547,10 +3593,12 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3582,8 +3630,7 @@ const deserializeAws_json1_0UpdateTableReplicaAutoScalingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3599,10 +3646,12 @@ const deserializeAws_json1_0UpdateTableReplicaAutoScalingCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3634,8 +3683,7 @@ const deserializeAws_json1_0UpdateTimeToLiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.dynamodb#InternalServerError": @@ -3654,10 +3702,12 @@ const deserializeAws_json1_0UpdateTimeToLiveCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8600,7 +8650,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8626,6 +8676,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ebs/src/protocols/Aws_restJson1.ts b/clients/client-ebs/src/protocols/Aws_restJson1.ts index 744bec8a326a2..2aed59460a9c4 100644 --- a/clients/client-ebs/src/protocols/Aws_restJson1.ts +++ b/clients/client-ebs/src/protocols/Aws_restJson1.ts @@ -301,8 +301,7 @@ const deserializeAws_restJson1CompleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -324,10 +323,12 @@ const deserializeAws_restJson1CompleteSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -370,8 +371,7 @@ const deserializeAws_restJson1GetSnapshotBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -393,10 +393,12 @@ const deserializeAws_restJson1GetSnapshotBlockCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -445,8 +447,7 @@ const deserializeAws_restJson1ListChangedBlocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -468,10 +469,12 @@ const deserializeAws_restJson1ListChangedBlocksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -520,8 +523,7 @@ const deserializeAws_restJson1ListSnapshotBlocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -543,10 +545,12 @@ const deserializeAws_restJson1ListSnapshotBlocksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -583,8 +587,7 @@ const deserializeAws_restJson1PutSnapshotBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -606,10 +609,12 @@ const deserializeAws_restJson1PutSnapshotBlockCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -678,8 +683,7 @@ const deserializeAws_restJson1StartSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ebs#AccessDeniedException": @@ -707,10 +711,12 @@ const deserializeAws_restJson1StartSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -972,7 +978,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -998,6 +1004,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ec2-instance-connect/src/protocols/Aws_json1_1.ts b/clients/client-ec2-instance-connect/src/protocols/Aws_json1_1.ts index 390e34207be5c..ffc3fab60caa6 100644 --- a/clients/client-ec2-instance-connect/src/protocols/Aws_json1_1.ts +++ b/clients/client-ec2-instance-connect/src/protocols/Aws_json1_1.ts @@ -87,8 +87,7 @@ const deserializeAws_json1_1SendSerialConsoleSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthException": case "com.amazonaws.ec2instanceconnect#AuthException": @@ -122,10 +121,12 @@ const deserializeAws_json1_1SendSerialConsoleSSHPublicKeyCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -157,8 +158,7 @@ const deserializeAws_json1_1SendSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthException": case "com.amazonaws.ec2instanceconnect#AuthException": @@ -180,10 +180,12 @@ const deserializeAws_json1_1SendSSHPublicKeyCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -494,7 +496,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -520,6 +522,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ec2/src/protocols/Aws_ec2.ts b/clients/client-ec2/src/protocols/Aws_ec2.ts index 01b84d66737d6..5f4331eb0bf5d 100644 --- a/clients/client-ec2/src/protocols/Aws_ec2.ts +++ b/clients/client-ec2/src/protocols/Aws_ec2.ts @@ -11815,15 +11815,16 @@ const deserializeAws_ec2AcceptReservedInstancesExchangeQuoteCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -11855,15 +11856,16 @@ const deserializeAws_ec2AcceptTransitGatewayMulticastDomainAssociationsCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -11895,15 +11897,16 @@ const deserializeAws_ec2AcceptTransitGatewayPeeringAttachmentCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -11935,15 +11938,16 @@ const deserializeAws_ec2AcceptTransitGatewayVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -11975,15 +11979,16 @@ const deserializeAws_ec2AcceptVpcEndpointConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12015,15 +12020,16 @@ const deserializeAws_ec2AcceptVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12055,15 +12061,16 @@ const deserializeAws_ec2AdvertiseByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12095,15 +12102,16 @@ const deserializeAws_ec2AllocateAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12135,15 +12143,16 @@ const deserializeAws_ec2AllocateHostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12175,15 +12184,16 @@ const deserializeAws_ec2AllocateIpamPoolCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12215,15 +12225,16 @@ const deserializeAws_ec2ApplySecurityGroupsToClientVpnTargetNetworkCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12255,15 +12266,16 @@ const deserializeAws_ec2AssignIpv6AddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12295,15 +12307,16 @@ const deserializeAws_ec2AssignPrivateIpAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12335,15 +12348,16 @@ const deserializeAws_ec2AssociateAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12375,15 +12389,16 @@ const deserializeAws_ec2AssociateClientVpnTargetNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12412,15 +12427,16 @@ const deserializeAws_ec2AssociateDhcpOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12452,15 +12468,16 @@ const deserializeAws_ec2AssociateEnclaveCertificateIamRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12492,15 +12509,16 @@ const deserializeAws_ec2AssociateIamInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12532,15 +12550,16 @@ const deserializeAws_ec2AssociateInstanceEventWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12572,15 +12591,16 @@ const deserializeAws_ec2AssociateRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12612,15 +12632,16 @@ const deserializeAws_ec2AssociateSubnetCidrBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12652,15 +12673,16 @@ const deserializeAws_ec2AssociateTransitGatewayMulticastDomainCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12692,15 +12714,16 @@ const deserializeAws_ec2AssociateTransitGatewayRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12732,15 +12755,16 @@ const deserializeAws_ec2AssociateTrunkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12772,15 +12796,16 @@ const deserializeAws_ec2AssociateVpcCidrBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12812,15 +12837,16 @@ const deserializeAws_ec2AttachClassicLinkVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12849,15 +12875,16 @@ const deserializeAws_ec2AttachInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12889,15 +12916,16 @@ const deserializeAws_ec2AttachNetworkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12929,15 +12957,16 @@ const deserializeAws_ec2AttachVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -12969,15 +12998,16 @@ const deserializeAws_ec2AttachVpnGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13009,15 +13039,16 @@ const deserializeAws_ec2AuthorizeClientVpnIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13049,15 +13080,16 @@ const deserializeAws_ec2AuthorizeSecurityGroupEgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13089,15 +13121,16 @@ const deserializeAws_ec2AuthorizeSecurityGroupIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13129,15 +13162,16 @@ const deserializeAws_ec2BundleInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13169,15 +13203,16 @@ const deserializeAws_ec2CancelBundleTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13209,15 +13244,16 @@ const deserializeAws_ec2CancelCapacityReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13249,15 +13285,16 @@ const deserializeAws_ec2CancelCapacityReservationFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13286,15 +13323,16 @@ const deserializeAws_ec2CancelConversionTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13323,15 +13361,16 @@ const deserializeAws_ec2CancelExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13363,15 +13402,16 @@ const deserializeAws_ec2CancelImportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13403,15 +13443,16 @@ const deserializeAws_ec2CancelReservedInstancesListingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13443,15 +13484,16 @@ const deserializeAws_ec2CancelSpotFleetRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13483,15 +13525,16 @@ const deserializeAws_ec2CancelSpotInstanceRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13523,15 +13566,16 @@ const deserializeAws_ec2ConfirmProductInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13563,15 +13607,16 @@ const deserializeAws_ec2CopyFpgaImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13603,15 +13648,16 @@ const deserializeAws_ec2CopyImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13643,15 +13689,16 @@ const deserializeAws_ec2CopySnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13683,15 +13730,16 @@ const deserializeAws_ec2CreateCapacityReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13723,15 +13771,16 @@ const deserializeAws_ec2CreateCapacityReservationFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13763,15 +13812,16 @@ const deserializeAws_ec2CreateCarrierGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13803,15 +13853,16 @@ const deserializeAws_ec2CreateClientVpnEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13843,15 +13894,16 @@ const deserializeAws_ec2CreateClientVpnRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13883,15 +13935,16 @@ const deserializeAws_ec2CreateCustomerGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13923,15 +13976,16 @@ const deserializeAws_ec2CreateDefaultSubnetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -13963,15 +14017,16 @@ const deserializeAws_ec2CreateDefaultVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14003,15 +14058,16 @@ const deserializeAws_ec2CreateDhcpOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14043,15 +14099,16 @@ const deserializeAws_ec2CreateEgressOnlyInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14083,15 +14140,16 @@ const deserializeAws_ec2CreateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14123,15 +14181,16 @@ const deserializeAws_ec2CreateFlowLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14163,15 +14222,16 @@ const deserializeAws_ec2CreateFpgaImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14203,15 +14263,16 @@ const deserializeAws_ec2CreateImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14243,15 +14304,16 @@ const deserializeAws_ec2CreateInstanceEventWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14283,15 +14345,16 @@ const deserializeAws_ec2CreateInstanceExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14323,15 +14386,16 @@ const deserializeAws_ec2CreateInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14363,15 +14427,16 @@ const deserializeAws_ec2CreateIpamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14403,15 +14468,16 @@ const deserializeAws_ec2CreateIpamPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14443,15 +14509,16 @@ const deserializeAws_ec2CreateIpamScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14483,15 +14550,16 @@ const deserializeAws_ec2CreateKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14523,15 +14591,16 @@ const deserializeAws_ec2CreateLaunchTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14563,15 +14632,16 @@ const deserializeAws_ec2CreateLaunchTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14603,15 +14673,16 @@ const deserializeAws_ec2CreateLocalGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14643,15 +14714,16 @@ const deserializeAws_ec2CreateLocalGatewayRouteTableVpcAssociationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14683,15 +14755,16 @@ const deserializeAws_ec2CreateManagedPrefixListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14723,15 +14796,16 @@ const deserializeAws_ec2CreateNatGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14763,15 +14837,16 @@ const deserializeAws_ec2CreateNetworkAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14800,15 +14875,16 @@ const deserializeAws_ec2CreateNetworkAclEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14840,15 +14916,16 @@ const deserializeAws_ec2CreateNetworkInsightsAccessScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14880,15 +14957,16 @@ const deserializeAws_ec2CreateNetworkInsightsPathCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14920,15 +14998,16 @@ const deserializeAws_ec2CreateNetworkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -14960,15 +15039,16 @@ const deserializeAws_ec2CreateNetworkInterfacePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15000,15 +15080,16 @@ const deserializeAws_ec2CreatePlacementGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15040,15 +15121,16 @@ const deserializeAws_ec2CreatePublicIpv4PoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15080,15 +15162,16 @@ const deserializeAws_ec2CreateReplaceRootVolumeTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15120,15 +15203,16 @@ const deserializeAws_ec2CreateReservedInstancesListingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15160,15 +15244,16 @@ const deserializeAws_ec2CreateRestoreImageTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15200,15 +15285,16 @@ const deserializeAws_ec2CreateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15240,15 +15326,16 @@ const deserializeAws_ec2CreateRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15280,15 +15367,16 @@ const deserializeAws_ec2CreateSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15320,15 +15408,16 @@ const deserializeAws_ec2CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15360,15 +15449,16 @@ const deserializeAws_ec2CreateSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15400,15 +15490,16 @@ const deserializeAws_ec2CreateSpotDatafeedSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15440,15 +15531,16 @@ const deserializeAws_ec2CreateStoreImageTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15480,15 +15572,16 @@ const deserializeAws_ec2CreateSubnetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15520,15 +15613,16 @@ const deserializeAws_ec2CreateSubnetCidrReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15557,15 +15651,16 @@ const deserializeAws_ec2CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15597,15 +15692,16 @@ const deserializeAws_ec2CreateTrafficMirrorFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15637,15 +15733,16 @@ const deserializeAws_ec2CreateTrafficMirrorFilterRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15677,15 +15774,16 @@ const deserializeAws_ec2CreateTrafficMirrorSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15717,15 +15815,16 @@ const deserializeAws_ec2CreateTrafficMirrorTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15757,15 +15856,16 @@ const deserializeAws_ec2CreateTransitGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15797,15 +15897,16 @@ const deserializeAws_ec2CreateTransitGatewayConnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15837,15 +15938,16 @@ const deserializeAws_ec2CreateTransitGatewayConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15877,15 +15979,16 @@ const deserializeAws_ec2CreateTransitGatewayMulticastDomainCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15917,15 +16020,16 @@ const deserializeAws_ec2CreateTransitGatewayPeeringAttachmentCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15957,15 +16061,16 @@ const deserializeAws_ec2CreateTransitGatewayPrefixListReferenceCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -15997,15 +16102,16 @@ const deserializeAws_ec2CreateTransitGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16037,15 +16143,16 @@ const deserializeAws_ec2CreateTransitGatewayRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16077,15 +16184,16 @@ const deserializeAws_ec2CreateTransitGatewayVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16117,15 +16225,16 @@ const deserializeAws_ec2CreateVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16157,15 +16266,16 @@ const deserializeAws_ec2CreateVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16197,15 +16307,16 @@ const deserializeAws_ec2CreateVpcEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16237,15 +16348,16 @@ const deserializeAws_ec2CreateVpcEndpointConnectionNotificationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16277,15 +16389,16 @@ const deserializeAws_ec2CreateVpcEndpointServiceConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16317,15 +16430,16 @@ const deserializeAws_ec2CreateVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16357,15 +16471,16 @@ const deserializeAws_ec2CreateVpnConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16394,15 +16509,16 @@ const deserializeAws_ec2CreateVpnConnectionRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16434,15 +16550,16 @@ const deserializeAws_ec2CreateVpnGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16474,15 +16591,16 @@ const deserializeAws_ec2DeleteCarrierGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16514,15 +16632,16 @@ const deserializeAws_ec2DeleteClientVpnEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16554,15 +16673,16 @@ const deserializeAws_ec2DeleteClientVpnRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16591,15 +16711,16 @@ const deserializeAws_ec2DeleteCustomerGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16628,15 +16749,16 @@ const deserializeAws_ec2DeleteDhcpOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16668,15 +16790,16 @@ const deserializeAws_ec2DeleteEgressOnlyInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16708,15 +16831,16 @@ const deserializeAws_ec2DeleteFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16748,15 +16872,16 @@ const deserializeAws_ec2DeleteFlowLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16788,15 +16913,16 @@ const deserializeAws_ec2DeleteFpgaImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16828,15 +16954,16 @@ const deserializeAws_ec2DeleteInstanceEventWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16865,15 +16992,16 @@ const deserializeAws_ec2DeleteInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16905,15 +17033,16 @@ const deserializeAws_ec2DeleteIpamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16945,15 +17074,16 @@ const deserializeAws_ec2DeleteIpamPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -16985,15 +17115,16 @@ const deserializeAws_ec2DeleteIpamScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17022,15 +17153,16 @@ const deserializeAws_ec2DeleteKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17062,15 +17194,16 @@ const deserializeAws_ec2DeleteLaunchTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17102,15 +17235,16 @@ const deserializeAws_ec2DeleteLaunchTemplateVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17142,15 +17276,16 @@ const deserializeAws_ec2DeleteLocalGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17182,15 +17317,16 @@ const deserializeAws_ec2DeleteLocalGatewayRouteTableVpcAssociationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17222,15 +17358,16 @@ const deserializeAws_ec2DeleteManagedPrefixListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17262,15 +17399,16 @@ const deserializeAws_ec2DeleteNatGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17299,15 +17437,16 @@ const deserializeAws_ec2DeleteNetworkAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17336,15 +17475,16 @@ const deserializeAws_ec2DeleteNetworkAclEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17376,15 +17516,16 @@ const deserializeAws_ec2DeleteNetworkInsightsAccessScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17416,15 +17557,16 @@ const deserializeAws_ec2DeleteNetworkInsightsAccessScopeAnalysisCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17456,15 +17598,16 @@ const deserializeAws_ec2DeleteNetworkInsightsAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17496,15 +17639,16 @@ const deserializeAws_ec2DeleteNetworkInsightsPathCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17533,15 +17677,16 @@ const deserializeAws_ec2DeleteNetworkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17573,15 +17718,16 @@ const deserializeAws_ec2DeleteNetworkInterfacePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17610,15 +17756,16 @@ const deserializeAws_ec2DeletePlacementGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17650,15 +17797,16 @@ const deserializeAws_ec2DeletePublicIpv4PoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17690,15 +17838,16 @@ const deserializeAws_ec2DeleteQueuedReservedInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17727,15 +17876,16 @@ const deserializeAws_ec2DeleteRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17764,15 +17914,16 @@ const deserializeAws_ec2DeleteRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17801,15 +17952,16 @@ const deserializeAws_ec2DeleteSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17838,15 +17990,16 @@ const deserializeAws_ec2DeleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17875,15 +18028,16 @@ const deserializeAws_ec2DeleteSpotDatafeedSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17912,15 +18066,16 @@ const deserializeAws_ec2DeleteSubnetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17952,15 +18107,16 @@ const deserializeAws_ec2DeleteSubnetCidrReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -17989,15 +18145,16 @@ const deserializeAws_ec2DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18029,15 +18186,16 @@ const deserializeAws_ec2DeleteTrafficMirrorFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18069,15 +18227,16 @@ const deserializeAws_ec2DeleteTrafficMirrorFilterRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18109,15 +18268,16 @@ const deserializeAws_ec2DeleteTrafficMirrorSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18149,15 +18309,16 @@ const deserializeAws_ec2DeleteTrafficMirrorTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18189,15 +18350,16 @@ const deserializeAws_ec2DeleteTransitGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18229,15 +18391,16 @@ const deserializeAws_ec2DeleteTransitGatewayConnectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18269,15 +18432,16 @@ const deserializeAws_ec2DeleteTransitGatewayConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18309,15 +18473,16 @@ const deserializeAws_ec2DeleteTransitGatewayMulticastDomainCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18349,15 +18514,16 @@ const deserializeAws_ec2DeleteTransitGatewayPeeringAttachmentCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18389,15 +18555,16 @@ const deserializeAws_ec2DeleteTransitGatewayPrefixListReferenceCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18429,15 +18596,16 @@ const deserializeAws_ec2DeleteTransitGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18469,15 +18637,16 @@ const deserializeAws_ec2DeleteTransitGatewayRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18509,15 +18678,16 @@ const deserializeAws_ec2DeleteTransitGatewayVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18546,15 +18716,16 @@ const deserializeAws_ec2DeleteVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18583,15 +18754,16 @@ const deserializeAws_ec2DeleteVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18623,15 +18795,16 @@ const deserializeAws_ec2DeleteVpcEndpointConnectionNotificationsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18663,15 +18836,16 @@ const deserializeAws_ec2DeleteVpcEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18703,15 +18877,16 @@ const deserializeAws_ec2DeleteVpcEndpointServiceConfigurationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18743,15 +18918,16 @@ const deserializeAws_ec2DeleteVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18780,15 +18956,16 @@ const deserializeAws_ec2DeleteVpnConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18817,15 +18994,16 @@ const deserializeAws_ec2DeleteVpnConnectionRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18854,15 +19032,16 @@ const deserializeAws_ec2DeleteVpnGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18894,15 +19073,16 @@ const deserializeAws_ec2DeprovisionByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18934,15 +19114,16 @@ const deserializeAws_ec2DeprovisionIpamPoolCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -18974,15 +19155,16 @@ const deserializeAws_ec2DeprovisionPublicIpv4PoolCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19011,15 +19193,16 @@ const deserializeAws_ec2DeregisterImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19051,15 +19234,16 @@ const deserializeAws_ec2DeregisterInstanceEventNotificationAttributesCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19091,15 +19275,16 @@ const deserializeAws_ec2DeregisterTransitGatewayMulticastGroupMembersCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19131,15 +19316,16 @@ const deserializeAws_ec2DeregisterTransitGatewayMulticastGroupSourcesCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19171,15 +19357,16 @@ const deserializeAws_ec2DescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19211,15 +19398,16 @@ const deserializeAws_ec2DescribeAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19251,15 +19439,16 @@ const deserializeAws_ec2DescribeAddressesAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19291,15 +19480,16 @@ const deserializeAws_ec2DescribeAggregateIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19331,15 +19521,16 @@ const deserializeAws_ec2DescribeAvailabilityZonesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19371,15 +19562,16 @@ const deserializeAws_ec2DescribeBundleTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19411,15 +19603,16 @@ const deserializeAws_ec2DescribeByoipCidrsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19451,15 +19644,16 @@ const deserializeAws_ec2DescribeCapacityReservationFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19491,15 +19685,16 @@ const deserializeAws_ec2DescribeCapacityReservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19531,15 +19726,16 @@ const deserializeAws_ec2DescribeCarrierGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19571,15 +19767,16 @@ const deserializeAws_ec2DescribeClassicLinkInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19611,15 +19808,16 @@ const deserializeAws_ec2DescribeClientVpnAuthorizationRulesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19651,15 +19849,16 @@ const deserializeAws_ec2DescribeClientVpnConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19691,15 +19890,16 @@ const deserializeAws_ec2DescribeClientVpnEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19731,15 +19931,16 @@ const deserializeAws_ec2DescribeClientVpnRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19771,15 +19972,16 @@ const deserializeAws_ec2DescribeClientVpnTargetNetworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19811,15 +20013,16 @@ const deserializeAws_ec2DescribeCoipPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19851,15 +20054,16 @@ const deserializeAws_ec2DescribeConversionTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19891,15 +20095,16 @@ const deserializeAws_ec2DescribeCustomerGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19931,15 +20136,16 @@ const deserializeAws_ec2DescribeDhcpOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -19971,15 +20177,16 @@ const deserializeAws_ec2DescribeEgressOnlyInternetGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20011,15 +20218,16 @@ const deserializeAws_ec2DescribeElasticGpusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20051,15 +20259,16 @@ const deserializeAws_ec2DescribeExportImageTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20091,15 +20300,16 @@ const deserializeAws_ec2DescribeExportTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20131,15 +20341,16 @@ const deserializeAws_ec2DescribeFastLaunchImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20171,15 +20382,16 @@ const deserializeAws_ec2DescribeFastSnapshotRestoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20211,15 +20423,16 @@ const deserializeAws_ec2DescribeFleetHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20251,15 +20464,16 @@ const deserializeAws_ec2DescribeFleetInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20291,15 +20505,16 @@ const deserializeAws_ec2DescribeFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20331,15 +20546,16 @@ const deserializeAws_ec2DescribeFlowLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20371,15 +20587,16 @@ const deserializeAws_ec2DescribeFpgaImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20411,15 +20628,16 @@ const deserializeAws_ec2DescribeFpgaImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20451,15 +20669,16 @@ const deserializeAws_ec2DescribeHostReservationOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20491,15 +20710,16 @@ const deserializeAws_ec2DescribeHostReservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20531,15 +20751,16 @@ const deserializeAws_ec2DescribeHostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20571,15 +20792,16 @@ const deserializeAws_ec2DescribeIamInstanceProfileAssociationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20611,15 +20833,16 @@ const deserializeAws_ec2DescribeIdentityIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20651,15 +20874,16 @@ const deserializeAws_ec2DescribeIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20691,15 +20915,16 @@ const deserializeAws_ec2DescribeImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20731,15 +20956,16 @@ const deserializeAws_ec2DescribeImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20771,15 +20997,16 @@ const deserializeAws_ec2DescribeImportImageTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20811,15 +21038,16 @@ const deserializeAws_ec2DescribeImportSnapshotTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20851,15 +21079,16 @@ const deserializeAws_ec2DescribeInstanceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20891,15 +21120,16 @@ const deserializeAws_ec2DescribeInstanceCreditSpecificationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20931,15 +21161,16 @@ const deserializeAws_ec2DescribeInstanceEventNotificationAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -20971,15 +21202,16 @@ const deserializeAws_ec2DescribeInstanceEventWindowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21011,15 +21243,16 @@ const deserializeAws_ec2DescribeInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21051,15 +21284,16 @@ const deserializeAws_ec2DescribeInstanceStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21091,15 +21325,16 @@ const deserializeAws_ec2DescribeInstanceTypeOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21131,15 +21366,16 @@ const deserializeAws_ec2DescribeInstanceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21171,15 +21407,16 @@ const deserializeAws_ec2DescribeInternetGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21211,15 +21448,16 @@ const deserializeAws_ec2DescribeIpamPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21251,15 +21489,16 @@ const deserializeAws_ec2DescribeIpamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21291,15 +21530,16 @@ const deserializeAws_ec2DescribeIpamScopesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21331,15 +21571,16 @@ const deserializeAws_ec2DescribeIpv6PoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21371,15 +21612,16 @@ const deserializeAws_ec2DescribeKeyPairsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21411,15 +21653,16 @@ const deserializeAws_ec2DescribeLaunchTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21451,15 +21694,16 @@ const deserializeAws_ec2DescribeLaunchTemplateVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21491,15 +21735,16 @@ const deserializeAws_ec2DescribeLocalGatewayRouteTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21534,15 +21779,16 @@ const deserializeAws_ec2DescribeLocalGatewayRouteTableVirtualInterfaceGroupAssoc body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21574,15 +21820,16 @@ const deserializeAws_ec2DescribeLocalGatewayRouteTableVpcAssociationsCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21614,15 +21861,16 @@ const deserializeAws_ec2DescribeLocalGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21654,15 +21902,16 @@ const deserializeAws_ec2DescribeLocalGatewayVirtualInterfaceGroupsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21694,15 +21943,16 @@ const deserializeAws_ec2DescribeLocalGatewayVirtualInterfacesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21734,15 +21984,16 @@ const deserializeAws_ec2DescribeManagedPrefixListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21774,15 +22025,16 @@ const deserializeAws_ec2DescribeMovingAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21814,15 +22066,16 @@ const deserializeAws_ec2DescribeNatGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21854,15 +22107,16 @@ const deserializeAws_ec2DescribeNetworkAclsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21894,15 +22148,16 @@ const deserializeAws_ec2DescribeNetworkInsightsAccessScopeAnalysesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21934,15 +22189,16 @@ const deserializeAws_ec2DescribeNetworkInsightsAccessScopesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -21974,15 +22230,16 @@ const deserializeAws_ec2DescribeNetworkInsightsAnalysesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22014,15 +22271,16 @@ const deserializeAws_ec2DescribeNetworkInsightsPathsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22054,15 +22312,16 @@ const deserializeAws_ec2DescribeNetworkInterfaceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22094,15 +22353,16 @@ const deserializeAws_ec2DescribeNetworkInterfacePermissionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22134,15 +22394,16 @@ const deserializeAws_ec2DescribeNetworkInterfacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22174,15 +22435,16 @@ const deserializeAws_ec2DescribePlacementGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22214,15 +22476,16 @@ const deserializeAws_ec2DescribePrefixListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22254,15 +22517,16 @@ const deserializeAws_ec2DescribePrincipalIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22294,15 +22558,16 @@ const deserializeAws_ec2DescribePublicIpv4PoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22334,15 +22599,16 @@ const deserializeAws_ec2DescribeRegionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22374,15 +22640,16 @@ const deserializeAws_ec2DescribeReplaceRootVolumeTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22414,15 +22681,16 @@ const deserializeAws_ec2DescribeReservedInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22454,15 +22722,16 @@ const deserializeAws_ec2DescribeReservedInstancesListingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22494,15 +22763,16 @@ const deserializeAws_ec2DescribeReservedInstancesModificationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22534,15 +22804,16 @@ const deserializeAws_ec2DescribeReservedInstancesOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22574,15 +22845,16 @@ const deserializeAws_ec2DescribeRouteTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22614,15 +22886,16 @@ const deserializeAws_ec2DescribeScheduledInstanceAvailabilityCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22654,15 +22927,16 @@ const deserializeAws_ec2DescribeScheduledInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22694,15 +22968,16 @@ const deserializeAws_ec2DescribeSecurityGroupReferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22734,15 +23009,16 @@ const deserializeAws_ec2DescribeSecurityGroupRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22774,15 +23050,16 @@ const deserializeAws_ec2DescribeSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22814,15 +23091,16 @@ const deserializeAws_ec2DescribeSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22854,15 +23132,16 @@ const deserializeAws_ec2DescribeSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22894,15 +23173,16 @@ const deserializeAws_ec2DescribeSnapshotTierStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22934,15 +23214,16 @@ const deserializeAws_ec2DescribeSpotDatafeedSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -22974,15 +23255,16 @@ const deserializeAws_ec2DescribeSpotFleetInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23014,15 +23296,16 @@ const deserializeAws_ec2DescribeSpotFleetRequestHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23054,15 +23337,16 @@ const deserializeAws_ec2DescribeSpotFleetRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23094,15 +23378,16 @@ const deserializeAws_ec2DescribeSpotInstanceRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23134,15 +23419,16 @@ const deserializeAws_ec2DescribeSpotPriceHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23174,15 +23460,16 @@ const deserializeAws_ec2DescribeStaleSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23214,15 +23501,16 @@ const deserializeAws_ec2DescribeStoreImageTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23254,15 +23542,16 @@ const deserializeAws_ec2DescribeSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23294,15 +23583,16 @@ const deserializeAws_ec2DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23334,15 +23624,16 @@ const deserializeAws_ec2DescribeTrafficMirrorFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23374,15 +23665,16 @@ const deserializeAws_ec2DescribeTrafficMirrorSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23414,15 +23706,16 @@ const deserializeAws_ec2DescribeTrafficMirrorTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23454,15 +23747,16 @@ const deserializeAws_ec2DescribeTransitGatewayAttachmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23494,15 +23788,16 @@ const deserializeAws_ec2DescribeTransitGatewayConnectPeersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23534,15 +23829,16 @@ const deserializeAws_ec2DescribeTransitGatewayConnectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23574,15 +23870,16 @@ const deserializeAws_ec2DescribeTransitGatewayMulticastDomainsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23614,15 +23911,16 @@ const deserializeAws_ec2DescribeTransitGatewayPeeringAttachmentsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23654,15 +23952,16 @@ const deserializeAws_ec2DescribeTransitGatewayRouteTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23694,15 +23993,16 @@ const deserializeAws_ec2DescribeTransitGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23734,15 +24034,16 @@ const deserializeAws_ec2DescribeTransitGatewayVpcAttachmentsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23774,15 +24075,16 @@ const deserializeAws_ec2DescribeTrunkInterfaceAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23814,15 +24116,16 @@ const deserializeAws_ec2DescribeVolumeAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23854,15 +24157,16 @@ const deserializeAws_ec2DescribeVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23894,15 +24198,16 @@ const deserializeAws_ec2DescribeVolumesModificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23934,15 +24239,16 @@ const deserializeAws_ec2DescribeVolumeStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -23974,15 +24280,16 @@ const deserializeAws_ec2DescribeVpcAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24014,15 +24321,16 @@ const deserializeAws_ec2DescribeVpcClassicLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24054,15 +24362,16 @@ const deserializeAws_ec2DescribeVpcClassicLinkDnsSupportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24094,15 +24403,16 @@ const deserializeAws_ec2DescribeVpcEndpointConnectionNotificationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24134,15 +24444,16 @@ const deserializeAws_ec2DescribeVpcEndpointConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24174,15 +24485,16 @@ const deserializeAws_ec2DescribeVpcEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24214,15 +24526,16 @@ const deserializeAws_ec2DescribeVpcEndpointServiceConfigurationsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24254,15 +24567,16 @@ const deserializeAws_ec2DescribeVpcEndpointServicePermissionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24294,15 +24608,16 @@ const deserializeAws_ec2DescribeVpcEndpointServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24334,15 +24649,16 @@ const deserializeAws_ec2DescribeVpcPeeringConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24374,15 +24690,16 @@ const deserializeAws_ec2DescribeVpcsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24414,15 +24731,16 @@ const deserializeAws_ec2DescribeVpnConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24454,15 +24772,16 @@ const deserializeAws_ec2DescribeVpnGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24494,15 +24813,16 @@ const deserializeAws_ec2DetachClassicLinkVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24531,15 +24851,16 @@ const deserializeAws_ec2DetachInternetGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24568,15 +24889,16 @@ const deserializeAws_ec2DetachNetworkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24608,15 +24930,16 @@ const deserializeAws_ec2DetachVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24645,15 +24968,16 @@ const deserializeAws_ec2DetachVpnGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24685,15 +25009,16 @@ const deserializeAws_ec2DisableEbsEncryptionByDefaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24725,15 +25050,16 @@ const deserializeAws_ec2DisableFastLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24765,15 +25091,16 @@ const deserializeAws_ec2DisableFastSnapshotRestoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24805,15 +25132,16 @@ const deserializeAws_ec2DisableImageDeprecationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24845,15 +25173,16 @@ const deserializeAws_ec2DisableIpamOrganizationAdminAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24885,15 +25214,16 @@ const deserializeAws_ec2DisableSerialConsoleAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24925,15 +25255,16 @@ const deserializeAws_ec2DisableTransitGatewayRouteTablePropagationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -24962,15 +25293,16 @@ const deserializeAws_ec2DisableVgwRoutePropagationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25002,15 +25334,16 @@ const deserializeAws_ec2DisableVpcClassicLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25042,15 +25375,16 @@ const deserializeAws_ec2DisableVpcClassicLinkDnsSupportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25079,15 +25413,16 @@ const deserializeAws_ec2DisassociateAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25119,15 +25454,16 @@ const deserializeAws_ec2DisassociateClientVpnTargetNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25159,15 +25495,16 @@ const deserializeAws_ec2DisassociateEnclaveCertificateIamRoleCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25199,15 +25536,16 @@ const deserializeAws_ec2DisassociateIamInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25239,15 +25577,16 @@ const deserializeAws_ec2DisassociateInstanceEventWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25276,15 +25615,16 @@ const deserializeAws_ec2DisassociateRouteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25316,15 +25656,16 @@ const deserializeAws_ec2DisassociateSubnetCidrBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25356,15 +25697,16 @@ const deserializeAws_ec2DisassociateTransitGatewayMulticastDomainCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25396,15 +25738,16 @@ const deserializeAws_ec2DisassociateTransitGatewayRouteTableCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25436,15 +25779,16 @@ const deserializeAws_ec2DisassociateTrunkInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25476,15 +25820,16 @@ const deserializeAws_ec2DisassociateVpcCidrBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25516,15 +25861,16 @@ const deserializeAws_ec2EnableEbsEncryptionByDefaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25556,15 +25902,16 @@ const deserializeAws_ec2EnableFastLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25596,15 +25943,16 @@ const deserializeAws_ec2EnableFastSnapshotRestoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25636,15 +25984,16 @@ const deserializeAws_ec2EnableImageDeprecationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25676,15 +26025,16 @@ const deserializeAws_ec2EnableIpamOrganizationAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25716,15 +26066,16 @@ const deserializeAws_ec2EnableSerialConsoleAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25756,15 +26107,16 @@ const deserializeAws_ec2EnableTransitGatewayRouteTablePropagationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25793,15 +26145,16 @@ const deserializeAws_ec2EnableVgwRoutePropagationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25830,15 +26183,16 @@ const deserializeAws_ec2EnableVolumeIOCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25870,15 +26224,16 @@ const deserializeAws_ec2EnableVpcClassicLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25910,15 +26265,16 @@ const deserializeAws_ec2EnableVpcClassicLinkDnsSupportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25950,15 +26306,16 @@ const deserializeAws_ec2ExportClientVpnClientCertificateRevocationListCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -25990,15 +26347,16 @@ const deserializeAws_ec2ExportClientVpnClientConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26030,15 +26388,16 @@ const deserializeAws_ec2ExportImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26070,15 +26429,16 @@ const deserializeAws_ec2ExportTransitGatewayRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26110,15 +26470,16 @@ const deserializeAws_ec2GetAssociatedEnclaveCertificateIamRolesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26150,15 +26511,16 @@ const deserializeAws_ec2GetAssociatedIpv6PoolCidrsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26190,15 +26552,16 @@ const deserializeAws_ec2GetCapacityReservationUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26230,15 +26593,16 @@ const deserializeAws_ec2GetCoipPoolUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26270,15 +26634,16 @@ const deserializeAws_ec2GetConsoleOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26310,15 +26675,16 @@ const deserializeAws_ec2GetConsoleScreenshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26350,15 +26716,16 @@ const deserializeAws_ec2GetDefaultCreditSpecificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26390,15 +26757,16 @@ const deserializeAws_ec2GetEbsDefaultKmsKeyIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26430,15 +26798,16 @@ const deserializeAws_ec2GetEbsEncryptionByDefaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26470,15 +26839,16 @@ const deserializeAws_ec2GetFlowLogsIntegrationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26510,15 +26880,16 @@ const deserializeAws_ec2GetGroupsForCapacityReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26550,15 +26921,16 @@ const deserializeAws_ec2GetHostReservationPurchasePreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26590,15 +26962,16 @@ const deserializeAws_ec2GetInstanceTypesFromInstanceRequirementsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26630,15 +27003,16 @@ const deserializeAws_ec2GetInstanceUefiDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26670,15 +27044,16 @@ const deserializeAws_ec2GetIpamAddressHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26710,15 +27085,16 @@ const deserializeAws_ec2GetIpamPoolAllocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26750,15 +27126,16 @@ const deserializeAws_ec2GetIpamPoolCidrsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26790,15 +27167,16 @@ const deserializeAws_ec2GetIpamResourceCidrsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26830,15 +27208,16 @@ const deserializeAws_ec2GetLaunchTemplateDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26870,15 +27249,16 @@ const deserializeAws_ec2GetManagedPrefixListAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26910,15 +27290,16 @@ const deserializeAws_ec2GetManagedPrefixListEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26950,15 +27331,16 @@ const deserializeAws_ec2GetNetworkInsightsAccessScopeAnalysisFindingsCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -26990,15 +27372,16 @@ const deserializeAws_ec2GetNetworkInsightsAccessScopeContentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27030,15 +27413,16 @@ const deserializeAws_ec2GetPasswordDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27070,15 +27454,16 @@ const deserializeAws_ec2GetReservedInstancesExchangeQuoteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27110,15 +27495,16 @@ const deserializeAws_ec2GetSerialConsoleAccessStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27150,15 +27536,16 @@ const deserializeAws_ec2GetSpotPlacementScoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27190,15 +27577,16 @@ const deserializeAws_ec2GetSubnetCidrReservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27230,15 +27618,16 @@ const deserializeAws_ec2GetTransitGatewayAttachmentPropagationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27270,15 +27659,16 @@ const deserializeAws_ec2GetTransitGatewayMulticastDomainAssociationsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27310,15 +27700,16 @@ const deserializeAws_ec2GetTransitGatewayPrefixListReferencesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27350,15 +27741,16 @@ const deserializeAws_ec2GetTransitGatewayRouteTableAssociationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27390,15 +27782,16 @@ const deserializeAws_ec2GetTransitGatewayRouteTablePropagationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27430,15 +27823,16 @@ const deserializeAws_ec2GetVpnConnectionDeviceSampleConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27470,15 +27864,16 @@ const deserializeAws_ec2GetVpnConnectionDeviceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27510,15 +27905,16 @@ const deserializeAws_ec2ImportClientVpnClientCertificateRevocationListCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27550,15 +27946,16 @@ const deserializeAws_ec2ImportImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27590,15 +27987,16 @@ const deserializeAws_ec2ImportInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27630,15 +28028,16 @@ const deserializeAws_ec2ImportKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27670,15 +28069,16 @@ const deserializeAws_ec2ImportSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27710,15 +28110,16 @@ const deserializeAws_ec2ImportVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27750,15 +28151,16 @@ const deserializeAws_ec2ListImagesInRecycleBinCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27790,15 +28192,16 @@ const deserializeAws_ec2ListSnapshotsInRecycleBinCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27830,15 +28233,16 @@ const deserializeAws_ec2ModifyAddressAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27870,15 +28274,16 @@ const deserializeAws_ec2ModifyAvailabilityZoneGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27910,15 +28315,16 @@ const deserializeAws_ec2ModifyCapacityReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27950,15 +28356,16 @@ const deserializeAws_ec2ModifyCapacityReservationFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -27990,15 +28397,16 @@ const deserializeAws_ec2ModifyClientVpnEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28030,15 +28438,16 @@ const deserializeAws_ec2ModifyDefaultCreditSpecificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28070,15 +28479,16 @@ const deserializeAws_ec2ModifyEbsDefaultKmsKeyIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28110,15 +28520,16 @@ const deserializeAws_ec2ModifyFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28150,15 +28561,16 @@ const deserializeAws_ec2ModifyFpgaImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28190,15 +28602,16 @@ const deserializeAws_ec2ModifyHostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28227,15 +28640,16 @@ const deserializeAws_ec2ModifyIdentityIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28264,15 +28678,16 @@ const deserializeAws_ec2ModifyIdFormatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28301,15 +28716,16 @@ const deserializeAws_ec2ModifyImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28338,15 +28754,16 @@ const deserializeAws_ec2ModifyInstanceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28378,15 +28795,16 @@ const deserializeAws_ec2ModifyInstanceCapacityReservationAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28418,15 +28836,16 @@ const deserializeAws_ec2ModifyInstanceCreditSpecificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28458,15 +28877,16 @@ const deserializeAws_ec2ModifyInstanceEventStartTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28498,15 +28918,16 @@ const deserializeAws_ec2ModifyInstanceEventWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28538,15 +28959,16 @@ const deserializeAws_ec2ModifyInstanceMaintenanceOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28578,15 +29000,16 @@ const deserializeAws_ec2ModifyInstanceMetadataOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28618,15 +29041,16 @@ const deserializeAws_ec2ModifyInstancePlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28658,15 +29082,16 @@ const deserializeAws_ec2ModifyIpamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28698,15 +29123,16 @@ const deserializeAws_ec2ModifyIpamPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28738,15 +29164,16 @@ const deserializeAws_ec2ModifyIpamResourceCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28778,15 +29205,16 @@ const deserializeAws_ec2ModifyIpamScopeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28818,15 +29246,16 @@ const deserializeAws_ec2ModifyLaunchTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28858,15 +29287,16 @@ const deserializeAws_ec2ModifyManagedPrefixListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28895,15 +29325,16 @@ const deserializeAws_ec2ModifyNetworkInterfaceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28935,15 +29366,16 @@ const deserializeAws_ec2ModifyPrivateDnsNameOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -28975,15 +29407,16 @@ const deserializeAws_ec2ModifyReservedInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29015,15 +29448,16 @@ const deserializeAws_ec2ModifySecurityGroupRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29052,15 +29486,16 @@ const deserializeAws_ec2ModifySnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29092,15 +29527,16 @@ const deserializeAws_ec2ModifySnapshotTierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29132,15 +29568,16 @@ const deserializeAws_ec2ModifySpotFleetRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29169,15 +29606,16 @@ const deserializeAws_ec2ModifySubnetAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29209,15 +29647,16 @@ const deserializeAws_ec2ModifyTrafficMirrorFilterNetworkServicesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29249,15 +29688,16 @@ const deserializeAws_ec2ModifyTrafficMirrorFilterRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29289,15 +29729,16 @@ const deserializeAws_ec2ModifyTrafficMirrorSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29329,15 +29770,16 @@ const deserializeAws_ec2ModifyTransitGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29369,15 +29811,16 @@ const deserializeAws_ec2ModifyTransitGatewayPrefixListReferenceCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29409,15 +29852,16 @@ const deserializeAws_ec2ModifyTransitGatewayVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29449,15 +29893,16 @@ const deserializeAws_ec2ModifyVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29486,15 +29931,16 @@ const deserializeAws_ec2ModifyVolumeAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29523,15 +29969,16 @@ const deserializeAws_ec2ModifyVpcAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29563,15 +30010,16 @@ const deserializeAws_ec2ModifyVpcEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29603,15 +30051,16 @@ const deserializeAws_ec2ModifyVpcEndpointConnectionNotificationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29643,15 +30092,16 @@ const deserializeAws_ec2ModifyVpcEndpointServiceConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29683,15 +30133,16 @@ const deserializeAws_ec2ModifyVpcEndpointServicePayerResponsibilityCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29723,15 +30174,16 @@ const deserializeAws_ec2ModifyVpcEndpointServicePermissionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29763,15 +30215,16 @@ const deserializeAws_ec2ModifyVpcPeeringConnectionOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29803,15 +30256,16 @@ const deserializeAws_ec2ModifyVpcTenancyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29843,15 +30297,16 @@ const deserializeAws_ec2ModifyVpnConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29883,15 +30338,16 @@ const deserializeAws_ec2ModifyVpnConnectionOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29923,15 +30379,16 @@ const deserializeAws_ec2ModifyVpnTunnelCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -29963,15 +30420,16 @@ const deserializeAws_ec2ModifyVpnTunnelOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30003,15 +30461,16 @@ const deserializeAws_ec2MonitorInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30043,15 +30502,16 @@ const deserializeAws_ec2MoveAddressToVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30083,15 +30543,16 @@ const deserializeAws_ec2MoveByoipCidrToIpamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30123,15 +30584,16 @@ const deserializeAws_ec2ProvisionByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30163,15 +30625,16 @@ const deserializeAws_ec2ProvisionIpamPoolCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30203,15 +30666,16 @@ const deserializeAws_ec2ProvisionPublicIpv4PoolCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30243,15 +30707,16 @@ const deserializeAws_ec2PurchaseHostReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30283,15 +30748,16 @@ const deserializeAws_ec2PurchaseReservedInstancesOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30323,15 +30789,16 @@ const deserializeAws_ec2PurchaseScheduledInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30360,15 +30827,16 @@ const deserializeAws_ec2RebootInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30400,15 +30868,16 @@ const deserializeAws_ec2RegisterImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30440,15 +30909,16 @@ const deserializeAws_ec2RegisterInstanceEventNotificationAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30480,15 +30950,16 @@ const deserializeAws_ec2RegisterTransitGatewayMulticastGroupMembersCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30520,15 +30991,16 @@ const deserializeAws_ec2RegisterTransitGatewayMulticastGroupSourcesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30560,15 +31032,16 @@ const deserializeAws_ec2RejectTransitGatewayMulticastDomainAssociationsCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30600,15 +31073,16 @@ const deserializeAws_ec2RejectTransitGatewayPeeringAttachmentCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30640,15 +31114,16 @@ const deserializeAws_ec2RejectTransitGatewayVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30680,15 +31155,16 @@ const deserializeAws_ec2RejectVpcEndpointConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30720,15 +31196,16 @@ const deserializeAws_ec2RejectVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30757,15 +31234,16 @@ const deserializeAws_ec2ReleaseAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30797,15 +31275,16 @@ const deserializeAws_ec2ReleaseHostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30837,15 +31316,16 @@ const deserializeAws_ec2ReleaseIpamPoolAllocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30877,15 +31357,16 @@ const deserializeAws_ec2ReplaceIamInstanceProfileAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30917,15 +31398,16 @@ const deserializeAws_ec2ReplaceNetworkAclAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30954,15 +31436,16 @@ const deserializeAws_ec2ReplaceNetworkAclEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -30991,15 +31474,16 @@ const deserializeAws_ec2ReplaceRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31031,15 +31515,16 @@ const deserializeAws_ec2ReplaceRouteTableAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31071,15 +31556,16 @@ const deserializeAws_ec2ReplaceTransitGatewayRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31108,15 +31594,16 @@ const deserializeAws_ec2ReportInstanceStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31148,15 +31635,16 @@ const deserializeAws_ec2RequestSpotFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31188,15 +31676,16 @@ const deserializeAws_ec2RequestSpotInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31228,15 +31717,16 @@ const deserializeAws_ec2ResetAddressAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31268,15 +31758,16 @@ const deserializeAws_ec2ResetEbsDefaultKmsKeyIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31308,15 +31799,16 @@ const deserializeAws_ec2ResetFpgaImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31345,15 +31837,16 @@ const deserializeAws_ec2ResetImageAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31382,15 +31875,16 @@ const deserializeAws_ec2ResetInstanceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31419,15 +31913,16 @@ const deserializeAws_ec2ResetNetworkInterfaceAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31456,15 +31951,16 @@ const deserializeAws_ec2ResetSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31496,15 +31992,16 @@ const deserializeAws_ec2RestoreAddressToClassicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31536,15 +32033,16 @@ const deserializeAws_ec2RestoreImageFromRecycleBinCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31576,15 +32074,16 @@ const deserializeAws_ec2RestoreManagedPrefixListVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31616,15 +32115,16 @@ const deserializeAws_ec2RestoreSnapshotFromRecycleBinCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31656,15 +32156,16 @@ const deserializeAws_ec2RestoreSnapshotTierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31696,15 +32197,16 @@ const deserializeAws_ec2RevokeClientVpnIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31736,15 +32238,16 @@ const deserializeAws_ec2RevokeSecurityGroupEgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31776,15 +32279,16 @@ const deserializeAws_ec2RevokeSecurityGroupIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31816,15 +32320,16 @@ const deserializeAws_ec2RunInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31856,15 +32361,16 @@ const deserializeAws_ec2RunScheduledInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31896,15 +32402,16 @@ const deserializeAws_ec2SearchLocalGatewayRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31936,15 +32443,16 @@ const deserializeAws_ec2SearchTransitGatewayMulticastGroupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -31976,15 +32484,16 @@ const deserializeAws_ec2SearchTransitGatewayRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32013,15 +32522,16 @@ const deserializeAws_ec2SendDiagnosticInterruptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32053,15 +32563,16 @@ const deserializeAws_ec2StartInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32093,15 +32604,16 @@ const deserializeAws_ec2StartNetworkInsightsAccessScopeAnalysisCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32133,15 +32645,16 @@ const deserializeAws_ec2StartNetworkInsightsAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32173,15 +32686,16 @@ const deserializeAws_ec2StartVpcEndpointServicePrivateDnsVerificationCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32213,15 +32727,16 @@ const deserializeAws_ec2StopInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32253,15 +32768,16 @@ const deserializeAws_ec2TerminateClientVpnConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32293,15 +32809,16 @@ const deserializeAws_ec2TerminateInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32333,15 +32850,16 @@ const deserializeAws_ec2UnassignIpv6AddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32370,15 +32888,16 @@ const deserializeAws_ec2UnassignPrivateIpAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32410,15 +32929,16 @@ const deserializeAws_ec2UnmonitorInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32450,15 +32970,16 @@ const deserializeAws_ec2UpdateSecurityGroupRuleDescriptionsEgressCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32490,15 +33011,16 @@ const deserializeAws_ec2UpdateSecurityGroupRuleDescriptionsIngressCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -32530,15 +33052,16 @@ const deserializeAws_ec2WithdrawByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -81671,12 +82194,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadEc2ErrorCode = (output: __HttpResponse, data: any): string => { +const loadEc2ErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Errors.Error.Code !== undefined) { return data.Errors.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-ecr-public/src/protocols/Aws_json1_1.ts b/clients/client-ecr-public/src/protocols/Aws_json1_1.ts index 6c0ace263e5b1..7053c28e69b8e 100644 --- a/clients/client-ecr-public/src/protocols/Aws_json1_1.ts +++ b/clients/client-ecr-public/src/protocols/Aws_json1_1.ts @@ -492,8 +492,7 @@ const deserializeAws_json1_1BatchCheckLayerAvailabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -509,10 +508,12 @@ const deserializeAws_json1_1BatchCheckLayerAvailabilityCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -544,8 +545,7 @@ const deserializeAws_json1_1BatchDeleteImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -558,10 +558,12 @@ const deserializeAws_json1_1BatchDeleteImageCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -593,8 +595,7 @@ const deserializeAws_json1_1CompleteLayerUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EmptyUploadException": case "com.amazonaws.ecrpublic#EmptyUploadException": @@ -628,10 +629,12 @@ const deserializeAws_json1_1CompleteLayerUploadCommandError = async ( throw await deserializeAws_json1_1UploadNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -663,8 +666,7 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -686,10 +688,12 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -721,8 +725,7 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -738,10 +741,12 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -773,8 +778,7 @@ const deserializeAws_json1_1DeleteRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -790,10 +794,12 @@ const deserializeAws_json1_1DeleteRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -825,8 +831,7 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageNotFoundException": case "com.amazonaws.ecrpublic#ImageNotFoundException": @@ -842,10 +847,12 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -877,8 +884,7 @@ const deserializeAws_json1_1DescribeImageTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -891,10 +897,12 @@ const deserializeAws_json1_1DescribeImageTagsCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -926,8 +934,7 @@ const deserializeAws_json1_1DescribeRegistriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -940,10 +947,12 @@ const deserializeAws_json1_1DescribeRegistriesCommandError = async ( throw await deserializeAws_json1_1UnsupportedCommandExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -975,8 +984,7 @@ const deserializeAws_json1_1DescribeRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -989,10 +997,12 @@ const deserializeAws_json1_1DescribeRepositoriesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1024,8 +1034,7 @@ const deserializeAws_json1_1GetAuthorizationTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1035,10 +1044,12 @@ const deserializeAws_json1_1GetAuthorizationTokenCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1070,8 +1081,7 @@ const deserializeAws_json1_1GetRegistryCatalogDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServerException": case "com.amazonaws.ecrpublic#ServerException": @@ -1081,10 +1091,12 @@ const deserializeAws_json1_1GetRegistryCatalogDataCommandError = async ( throw await deserializeAws_json1_1UnsupportedCommandExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1116,8 +1128,7 @@ const deserializeAws_json1_1GetRepositoryCatalogDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1130,10 +1141,12 @@ const deserializeAws_json1_1GetRepositoryCatalogDataCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1165,8 +1178,7 @@ const deserializeAws_json1_1GetRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1182,10 +1194,12 @@ const deserializeAws_json1_1GetRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1217,8 +1231,7 @@ const deserializeAws_json1_1InitiateLayerUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1237,10 +1250,12 @@ const deserializeAws_json1_1InitiateLayerUploadCommandError = async ( throw await deserializeAws_json1_1UnsupportedCommandExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1272,8 +1287,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1286,10 +1300,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1321,8 +1337,7 @@ const deserializeAws_json1_1PutImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageAlreadyExistsException": case "com.amazonaws.ecrpublic#ImageAlreadyExistsException": @@ -1359,10 +1374,12 @@ const deserializeAws_json1_1PutImageCommandError = async ( throw await deserializeAws_json1_1UnsupportedCommandExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1394,8 +1411,7 @@ const deserializeAws_json1_1PutRegistryCatalogDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1408,10 +1424,12 @@ const deserializeAws_json1_1PutRegistryCatalogDataCommandError = async ( throw await deserializeAws_json1_1UnsupportedCommandExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1443,8 +1461,7 @@ const deserializeAws_json1_1PutRepositoryCatalogDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1457,10 +1474,12 @@ const deserializeAws_json1_1PutRepositoryCatalogDataCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1492,8 +1511,7 @@ const deserializeAws_json1_1SetRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1506,10 +1524,12 @@ const deserializeAws_json1_1SetRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1541,8 +1561,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1561,10 +1580,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1596,8 +1617,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecrpublic#InvalidParameterException": @@ -1616,10 +1636,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1673,7 @@ const deserializeAws_json1_1UploadLayerPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLayerPartException": case "com.amazonaws.ecrpublic#InvalidLayerPartException": @@ -1680,10 +1701,12 @@ const deserializeAws_json1_1UploadLayerPartCommandError = async ( throw await deserializeAws_json1_1UploadNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3207,7 +3230,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3233,6 +3256,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ecr/src/protocols/Aws_json1_1.ts b/clients/client-ecr/src/protocols/Aws_json1_1.ts index 71c0260832eb9..b27e4395d57ac 100644 --- a/clients/client-ecr/src/protocols/Aws_json1_1.ts +++ b/clients/client-ecr/src/protocols/Aws_json1_1.ts @@ -858,8 +858,7 @@ const deserializeAws_json1_1BatchCheckLayerAvailabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -872,10 +871,12 @@ const deserializeAws_json1_1BatchCheckLayerAvailabilityCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -907,8 +908,7 @@ const deserializeAws_json1_1BatchDeleteImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -921,10 +921,12 @@ const deserializeAws_json1_1BatchDeleteImageCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -956,8 +958,7 @@ const deserializeAws_json1_1BatchGetImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -970,10 +971,12 @@ const deserializeAws_json1_1BatchGetImageCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1005,8 +1008,7 @@ const deserializeAws_json1_1BatchGetRepositoryScanningConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1022,10 +1024,12 @@ const deserializeAws_json1_1BatchGetRepositoryScanningConfigurationCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1057,8 +1061,7 @@ const deserializeAws_json1_1CompleteLayerUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EmptyUploadException": case "com.amazonaws.ecr#EmptyUploadException": @@ -1089,10 +1092,12 @@ const deserializeAws_json1_1CompleteLayerUploadCommandError = async ( throw await deserializeAws_json1_1UploadNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1124,8 +1129,7 @@ const deserializeAws_json1_1CreatePullThroughCacheRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1147,10 +1151,12 @@ const deserializeAws_json1_1CreatePullThroughCacheRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1188,7 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1208,10 +1213,12 @@ const deserializeAws_json1_1CreateRepositoryCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1250,7 @@ const deserializeAws_json1_1DeleteLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1260,10 +1266,12 @@ const deserializeAws_json1_1DeleteLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1295,8 +1303,7 @@ const deserializeAws_json1_1DeletePullThroughCacheRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1312,10 +1319,12 @@ const deserializeAws_json1_1DeletePullThroughCacheRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1347,8 +1356,7 @@ const deserializeAws_json1_1DeleteRegistryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1364,10 +1372,12 @@ const deserializeAws_json1_1DeleteRegistryPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1399,8 +1409,7 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1419,10 +1428,12 @@ const deserializeAws_json1_1DeleteRepositoryCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1454,8 +1465,7 @@ const deserializeAws_json1_1DeleteRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1471,10 +1481,12 @@ const deserializeAws_json1_1DeleteRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1506,8 +1518,7 @@ const deserializeAws_json1_1DescribeImageReplicationStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageNotFoundException": case "com.amazonaws.ecr#ImageNotFoundException": @@ -1526,10 +1537,12 @@ const deserializeAws_json1_1DescribeImageReplicationStatusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1561,8 +1574,7 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageNotFoundException": case "com.amazonaws.ecr#ImageNotFoundException": @@ -1578,10 +1590,12 @@ const deserializeAws_json1_1DescribeImagesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1613,8 +1627,7 @@ const deserializeAws_json1_1DescribeImageScanFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageNotFoundException": case "com.amazonaws.ecr#ImageNotFoundException": @@ -1636,10 +1649,12 @@ const deserializeAws_json1_1DescribeImageScanFindingsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1671,8 +1686,7 @@ const deserializeAws_json1_1DescribePullThroughCacheRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1688,10 +1702,12 @@ const deserializeAws_json1_1DescribePullThroughCacheRulesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1739,7 @@ const deserializeAws_json1_1DescribeRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1737,10 +1752,12 @@ const deserializeAws_json1_1DescribeRegistryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1772,8 +1789,7 @@ const deserializeAws_json1_1DescribeRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1786,10 +1802,12 @@ const deserializeAws_json1_1DescribeRepositoriesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1821,8 +1839,7 @@ const deserializeAws_json1_1GetAuthorizationTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1832,10 +1849,12 @@ const deserializeAws_json1_1GetAuthorizationTokenCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1867,8 +1886,7 @@ const deserializeAws_json1_1GetDownloadUrlForLayerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1887,10 +1905,12 @@ const deserializeAws_json1_1GetDownloadUrlForLayerCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1922,8 +1942,7 @@ const deserializeAws_json1_1GetLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1939,10 +1958,12 @@ const deserializeAws_json1_1GetLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1974,8 +1995,7 @@ const deserializeAws_json1_1GetLifecyclePolicyPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -1991,10 +2011,12 @@ const deserializeAws_json1_1GetLifecyclePolicyPreviewCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2026,8 +2048,7 @@ const deserializeAws_json1_1GetRegistryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2043,10 +2064,12 @@ const deserializeAws_json1_1GetRegistryPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2078,8 +2101,7 @@ const deserializeAws_json1_1GetRegistryScanningConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2092,10 +2114,12 @@ const deserializeAws_json1_1GetRegistryScanningConfigurationCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2127,8 +2151,7 @@ const deserializeAws_json1_1GetRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2144,10 +2167,12 @@ const deserializeAws_json1_1GetRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2179,8 +2204,7 @@ const deserializeAws_json1_1InitiateLayerUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2196,10 +2220,12 @@ const deserializeAws_json1_1InitiateLayerUploadCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2231,8 +2257,7 @@ const deserializeAws_json1_1ListImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2245,10 +2270,12 @@ const deserializeAws_json1_1ListImagesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2280,8 +2307,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2294,10 +2320,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2329,8 +2357,7 @@ const deserializeAws_json1_1PutImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageAlreadyExistsException": case "com.amazonaws.ecr#ImageAlreadyExistsException": @@ -2364,10 +2391,12 @@ const deserializeAws_json1_1PutImageCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2399,8 +2428,7 @@ const deserializeAws_json1_1PutImageScanningConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2416,10 +2444,12 @@ const deserializeAws_json1_1PutImageScanningConfigurationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2451,8 +2481,7 @@ const deserializeAws_json1_1PutImageTagMutabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2465,10 +2494,12 @@ const deserializeAws_json1_1PutImageTagMutabilityCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2500,8 +2531,7 @@ const deserializeAws_json1_1PutLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2514,10 +2544,12 @@ const deserializeAws_json1_1PutLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2549,8 +2581,7 @@ const deserializeAws_json1_1PutRegistryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2563,10 +2594,12 @@ const deserializeAws_json1_1PutRegistryPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2598,8 +2631,7 @@ const deserializeAws_json1_1PutRegistryScanningConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2612,10 +2644,12 @@ const deserializeAws_json1_1PutRegistryScanningConfigurationCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2647,8 +2681,7 @@ const deserializeAws_json1_1PutReplicationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2661,10 +2694,12 @@ const deserializeAws_json1_1PutReplicationConfigurationCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2696,8 +2731,7 @@ const deserializeAws_json1_1SetRepositoryPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2710,10 +2744,12 @@ const deserializeAws_json1_1SetRepositoryPolicyCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2745,8 +2781,7 @@ const deserializeAws_json1_1StartImageScanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ImageNotFoundException": case "com.amazonaws.ecr#ImageNotFoundException": @@ -2771,10 +2806,12 @@ const deserializeAws_json1_1StartImageScanCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2806,8 +2843,7 @@ const deserializeAws_json1_1StartLifecyclePolicyPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2826,10 +2862,12 @@ const deserializeAws_json1_1StartLifecyclePolicyPreviewCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2861,8 +2899,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2881,10 +2918,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2916,8 +2955,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ecr#InvalidParameterException": @@ -2936,10 +2974,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2971,8 +3011,7 @@ const deserializeAws_json1_1UploadLayerPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLayerPartException": case "com.amazonaws.ecr#InvalidLayerPartException": @@ -2997,10 +3036,12 @@ const deserializeAws_json1_1UploadLayerPartCommandError = async ( throw await deserializeAws_json1_1UploadNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6025,7 +6066,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6051,6 +6092,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ecs/src/protocols/Aws_json1_1.ts b/clients/client-ecs/src/protocols/Aws_json1_1.ts index 09b9f78b354eb..3a8f2503bdfba 100644 --- a/clients/client-ecs/src/protocols/Aws_json1_1.ts +++ b/clients/client-ecs/src/protocols/Aws_json1_1.ts @@ -1072,8 +1072,7 @@ const deserializeAws_json1_1CreateCapacityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1092,10 +1091,12 @@ const deserializeAws_json1_1CreateCapacityProviderCommandError = async ( throw await deserializeAws_json1_1UpdateInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1127,8 +1128,7 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1141,10 +1141,12 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1176,8 +1178,7 @@ const deserializeAws_json1_1CreateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -1205,10 +1206,12 @@ const deserializeAws_json1_1CreateServiceCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1240,8 +1243,7 @@ const deserializeAws_json1_1CreateTaskSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -1275,10 +1277,12 @@ const deserializeAws_json1_1CreateTaskSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1310,8 +1314,7 @@ const deserializeAws_json1_1DeleteAccountSettingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1324,10 +1327,12 @@ const deserializeAws_json1_1DeleteAccountSettingCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1359,8 +1364,7 @@ const deserializeAws_json1_1DeleteAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundException": case "com.amazonaws.ecs#ClusterNotFoundException": @@ -1373,10 +1377,12 @@ const deserializeAws_json1_1DeleteAttributesCommandError = async ( throw await deserializeAws_json1_1TargetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1408,8 +1414,7 @@ const deserializeAws_json1_1DeleteCapacityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1422,10 +1427,12 @@ const deserializeAws_json1_1DeleteCapacityProviderCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1457,8 +1464,7 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1486,10 +1492,12 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( throw await deserializeAws_json1_1UpdateInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1529,7 @@ const deserializeAws_json1_1DeleteServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1541,10 +1548,12 @@ const deserializeAws_json1_1DeleteServiceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1576,8 +1585,7 @@ const deserializeAws_json1_1DeleteTaskSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -1608,10 +1616,12 @@ const deserializeAws_json1_1DeleteTaskSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1643,8 +1653,7 @@ const deserializeAws_json1_1DeregisterContainerInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1660,10 +1669,12 @@ const deserializeAws_json1_1DeregisterContainerInstanceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1695,8 +1706,7 @@ const deserializeAws_json1_1DeregisterTaskDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1709,10 +1719,12 @@ const deserializeAws_json1_1DeregisterTaskDefinitionCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1744,8 +1756,7 @@ const deserializeAws_json1_1DescribeCapacityProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1758,10 +1769,12 @@ const deserializeAws_json1_1DescribeCapacityProvidersCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1793,8 +1806,7 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1807,10 +1819,12 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1842,8 +1856,7 @@ const deserializeAws_json1_1DescribeContainerInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1859,10 +1872,12 @@ const deserializeAws_json1_1DescribeContainerInstancesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1894,8 +1909,7 @@ const deserializeAws_json1_1DescribeServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1911,10 +1925,12 @@ const deserializeAws_json1_1DescribeServicesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1946,8 +1962,7 @@ const deserializeAws_json1_1DescribeTaskDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -1960,10 +1975,12 @@ const deserializeAws_json1_1DescribeTaskDefinitionCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1995,8 +2012,7 @@ const deserializeAws_json1_1DescribeTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2012,10 +2028,12 @@ const deserializeAws_json1_1DescribeTasksCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2047,8 +2065,7 @@ const deserializeAws_json1_1DescribeTaskSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -2076,10 +2093,12 @@ const deserializeAws_json1_1DescribeTaskSetsCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2111,8 +2130,7 @@ const deserializeAws_json1_1DiscoverPollEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2122,10 +2140,12 @@ const deserializeAws_json1_1DiscoverPollEndpointCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2157,8 +2177,7 @@ const deserializeAws_json1_1ExecuteCommandCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -2180,10 +2199,12 @@ const deserializeAws_json1_1ExecuteCommandCommandError = async ( throw await deserializeAws_json1_1TargetNotConnectedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2215,8 +2236,7 @@ const deserializeAws_json1_1ListAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2229,10 +2249,12 @@ const deserializeAws_json1_1ListAccountSettingsCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2264,8 +2286,7 @@ const deserializeAws_json1_1ListAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundException": case "com.amazonaws.ecs#ClusterNotFoundException": @@ -2275,10 +2296,12 @@ const deserializeAws_json1_1ListAttributesCommandError = async ( throw await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2310,8 +2333,7 @@ const deserializeAws_json1_1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2324,10 +2346,12 @@ const deserializeAws_json1_1ListClustersCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2359,8 +2383,7 @@ const deserializeAws_json1_1ListContainerInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2376,10 +2399,12 @@ const deserializeAws_json1_1ListContainerInstancesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2411,8 +2436,7 @@ const deserializeAws_json1_1ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2428,10 +2452,12 @@ const deserializeAws_json1_1ListServicesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2463,8 +2489,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2480,10 +2505,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2515,8 +2542,7 @@ const deserializeAws_json1_1ListTaskDefinitionFamiliesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2529,10 +2555,12 @@ const deserializeAws_json1_1ListTaskDefinitionFamiliesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2564,8 +2592,7 @@ const deserializeAws_json1_1ListTaskDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2578,10 +2605,12 @@ const deserializeAws_json1_1ListTaskDefinitionsCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2613,8 +2642,7 @@ const deserializeAws_json1_1ListTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2633,10 +2661,12 @@ const deserializeAws_json1_1ListTasksCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2668,8 +2698,7 @@ const deserializeAws_json1_1PutAccountSettingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2682,10 +2711,12 @@ const deserializeAws_json1_1PutAccountSettingCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2717,8 +2748,7 @@ const deserializeAws_json1_1PutAccountSettingDefaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2731,10 +2761,12 @@ const deserializeAws_json1_1PutAccountSettingDefaultCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2766,8 +2798,7 @@ const deserializeAws_json1_1PutAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AttributeLimitExceededException": case "com.amazonaws.ecs#AttributeLimitExceededException": @@ -2783,10 +2814,12 @@ const deserializeAws_json1_1PutAttributesCommandError = async ( throw await deserializeAws_json1_1TargetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2818,8 +2851,7 @@ const deserializeAws_json1_1PutClusterCapacityProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2841,10 +2873,12 @@ const deserializeAws_json1_1PutClusterCapacityProvidersCommandError = async ( throw await deserializeAws_json1_1UpdateInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2876,8 +2910,7 @@ const deserializeAws_json1_1RegisterContainerInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2890,10 +2923,12 @@ const deserializeAws_json1_1RegisterContainerInstanceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2925,8 +2960,7 @@ const deserializeAws_json1_1RegisterTaskDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -2939,10 +2973,12 @@ const deserializeAws_json1_1RegisterTaskDefinitionCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2974,8 +3010,7 @@ const deserializeAws_json1_1RunTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3006,10 +3041,12 @@ const deserializeAws_json1_1RunTaskCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3041,8 +3078,7 @@ const deserializeAws_json1_1StartTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3058,10 +3094,12 @@ const deserializeAws_json1_1StartTaskCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3093,8 +3131,7 @@ const deserializeAws_json1_1StopTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3110,10 +3147,12 @@ const deserializeAws_json1_1StopTaskCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3145,8 +3184,7 @@ const deserializeAws_json1_1SubmitAttachmentStateChangesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3162,10 +3200,12 @@ const deserializeAws_json1_1SubmitAttachmentStateChangesCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3197,8 +3237,7 @@ const deserializeAws_json1_1SubmitContainerStateChangeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3211,10 +3250,12 @@ const deserializeAws_json1_1SubmitContainerStateChangeCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3246,8 +3287,7 @@ const deserializeAws_json1_1SubmitTaskStateChangeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3263,10 +3303,12 @@ const deserializeAws_json1_1SubmitTaskStateChangeCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3298,8 +3340,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3318,10 +3359,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3353,8 +3396,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3373,10 +3415,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3408,8 +3452,7 @@ const deserializeAws_json1_1UpdateCapacityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3422,10 +3465,12 @@ const deserializeAws_json1_1UpdateCapacityProviderCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3457,8 +3502,7 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3474,10 +3518,12 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3509,8 +3555,7 @@ const deserializeAws_json1_1UpdateClusterSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3526,10 +3571,12 @@ const deserializeAws_json1_1UpdateClusterSettingsCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3561,8 +3608,7 @@ const deserializeAws_json1_1UpdateContainerAgentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3587,10 +3633,12 @@ const deserializeAws_json1_1UpdateContainerAgentCommandError = async ( throw await deserializeAws_json1_1UpdateInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3622,8 +3670,7 @@ const deserializeAws_json1_1UpdateContainerInstancesStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.ecs#ClientException": @@ -3639,10 +3686,12 @@ const deserializeAws_json1_1UpdateContainerInstancesStateCommandError = async ( throw await deserializeAws_json1_1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3674,8 +3723,7 @@ const deserializeAws_json1_1UpdateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3706,10 +3754,12 @@ const deserializeAws_json1_1UpdateServiceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3741,8 +3791,7 @@ const deserializeAws_json1_1UpdateServicePrimaryTaskSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3773,10 +3822,12 @@ const deserializeAws_json1_1UpdateServicePrimaryTaskSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3808,8 +3859,7 @@ const deserializeAws_json1_1UpdateTaskSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ecs#AccessDeniedException": @@ -3840,10 +3890,12 @@ const deserializeAws_json1_1UpdateTaskSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9095,7 +9147,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9121,6 +9173,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-efs/src/protocols/Aws_restJson1.ts b/clients/client-efs/src/protocols/Aws_restJson1.ts index 711e09b465cd6..a775fbd5048ba 100644 --- a/clients/client-efs/src/protocols/Aws_restJson1.ts +++ b/clients/client-efs/src/protocols/Aws_restJson1.ts @@ -1177,8 +1177,7 @@ const deserializeAws_restJson1CreateAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointAlreadyExists": case "com.amazonaws.efs#AccessPointAlreadyExists": @@ -1203,10 +1202,12 @@ const deserializeAws_restJson1CreateAccessPointCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1303,8 +1304,7 @@ const deserializeAws_restJson1CreateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1329,10 +1329,12 @@ const deserializeAws_restJson1CreateFileSystemCommandError = async ( throw await deserializeAws_restJson1UnsupportedAvailabilityZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1401,8 +1403,7 @@ const deserializeAws_restJson1CreateMountTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AvailabilityZonesMismatch": case "com.amazonaws.efs#AvailabilityZonesMismatch": @@ -1445,10 +1446,12 @@ const deserializeAws_restJson1CreateMountTargetCommandError = async ( throw await deserializeAws_restJson1UnsupportedAvailabilityZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1501,8 +1504,7 @@ const deserializeAws_restJson1CreateReplicationConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1536,10 +1538,12 @@ const deserializeAws_restJson1CreateReplicationConfigurationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1568,8 +1572,7 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1582,10 +1585,12 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1614,8 +1619,7 @@ const deserializeAws_restJson1DeleteAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -1628,10 +1632,12 @@ const deserializeAws_restJson1DeleteAccessPointCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1660,8 +1666,7 @@ const deserializeAws_restJson1DeleteFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1677,10 +1682,12 @@ const deserializeAws_restJson1DeleteFileSystemCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1709,8 +1716,7 @@ const deserializeAws_restJson1DeleteFileSystemPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1726,10 +1732,12 @@ const deserializeAws_restJson1DeleteFileSystemPolicyCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1758,8 +1766,7 @@ const deserializeAws_restJson1DeleteMountTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1775,10 +1782,12 @@ const deserializeAws_restJson1DeleteMountTargetCommandError = async ( throw await deserializeAws_restJson1MountTargetNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1807,8 +1816,7 @@ const deserializeAws_restJson1DeleteReplicationConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1824,10 +1832,12 @@ const deserializeAws_restJson1DeleteReplicationConfigurationCommandError = async throw await deserializeAws_restJson1ReplicationNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1856,8 +1866,7 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -1870,10 +1879,12 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1910,8 +1921,7 @@ const deserializeAws_restJson1DescribeAccessPointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -1927,10 +1937,12 @@ const deserializeAws_restJson1DescribeAccessPointsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1967,18 +1979,19 @@ const deserializeAws_restJson1DescribeAccountPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.efs#InternalServerError": throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2011,8 +2024,7 @@ const deserializeAws_restJson1DescribeBackupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2031,10 +2043,12 @@ const deserializeAws_restJson1DescribeBackupPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2071,8 +2085,7 @@ const deserializeAws_restJson1DescribeFileSystemPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2088,10 +2101,12 @@ const deserializeAws_restJson1DescribeFileSystemPolicyCommandError = async ( throw await deserializeAws_restJson1PolicyNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2132,8 +2147,7 @@ const deserializeAws_restJson1DescribeFileSystemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2146,10 +2160,12 @@ const deserializeAws_restJson1DescribeFileSystemsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2198,7 @@ const deserializeAws_restJson1DescribeLifecycleConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2196,10 +2211,12 @@ const deserializeAws_restJson1DescribeLifecycleConfigurationCommandError = async throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2240,8 +2257,7 @@ const deserializeAws_restJson1DescribeMountTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -2260,10 +2276,12 @@ const deserializeAws_restJson1DescribeMountTargetsCommandError = async ( throw await deserializeAws_restJson1MountTargetNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2296,8 +2314,7 @@ const deserializeAws_restJson1DescribeMountTargetSecurityGroupsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2313,10 +2330,12 @@ const deserializeAws_restJson1DescribeMountTargetSecurityGroupsCommandError = as throw await deserializeAws_restJson1MountTargetNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2353,8 +2372,7 @@ const deserializeAws_restJson1DescribeReplicationConfigurationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2373,10 +2391,12 @@ const deserializeAws_restJson1DescribeReplicationConfigurationsCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2417,8 +2437,7 @@ const deserializeAws_restJson1DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2431,10 +2450,12 @@ const deserializeAws_restJson1DescribeTagsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2471,8 +2492,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -2488,10 +2508,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2520,8 +2542,7 @@ const deserializeAws_restJson1ModifyMountTargetSecurityGroupsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2543,10 +2564,12 @@ const deserializeAws_restJson1ModifyMountTargetSecurityGroupsCommandError = asyn throw await deserializeAws_restJson1SecurityGroupNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2579,8 +2602,7 @@ const deserializeAws_restJson1PutAccountPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2590,10 +2612,12 @@ const deserializeAws_restJson1PutAccountPreferencesCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2626,8 +2650,7 @@ const deserializeAws_restJson1PutBackupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2646,10 +2669,12 @@ const deserializeAws_restJson1PutBackupPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2686,8 +2711,7 @@ const deserializeAws_restJson1PutFileSystemPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2706,10 +2730,12 @@ const deserializeAws_restJson1PutFileSystemPolicyCommandError = async ( throw await deserializeAws_restJson1InvalidPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2742,8 +2768,7 @@ const deserializeAws_restJson1PutLifecycleConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2759,10 +2784,12 @@ const deserializeAws_restJson1PutLifecycleConfigurationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2791,8 +2818,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -2808,10 +2834,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2840,8 +2868,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFound": case "com.amazonaws.efs#AccessPointNotFound": @@ -2857,10 +2884,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2957,8 +2986,7 @@ const deserializeAws_restJson1UpdateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.efs#BadRequest": @@ -2983,10 +3011,12 @@ const deserializeAws_restJson1UpdateFileSystemCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4042,7 +4072,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4068,6 +4098,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-eks/src/protocols/Aws_restJson1.ts b/clients/client-eks/src/protocols/Aws_restJson1.ts index 790d5fb66e2b0..904bcc737b1f2 100644 --- a/clients/client-eks/src/protocols/Aws_restJson1.ts +++ b/clients/client-eks/src/protocols/Aws_restJson1.ts @@ -1481,8 +1481,7 @@ const deserializeAws_restJson1AssociateEncryptionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1504,10 +1503,12 @@ const deserializeAws_restJson1AssociateEncryptionConfigCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1545,7 @@ const deserializeAws_restJson1AssociateIdentityProviderConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1567,10 +1567,12 @@ const deserializeAws_restJson1AssociateIdentityProviderConfigCommandError = asyn throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1605,7 @@ const deserializeAws_restJson1CreateAddonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1626,10 +1627,12 @@ const deserializeAws_restJson1CreateAddonCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1662,8 +1665,7 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1688,10 +1690,12 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( throw await deserializeAws_restJson1UnsupportedAvailabilityZoneExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1724,8 +1728,7 @@ const deserializeAws_restJson1CreateFargateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1747,10 +1750,12 @@ const deserializeAws_restJson1CreateFargateProfileCommandError = async ( throw await deserializeAws_restJson1UnsupportedAvailabilityZoneExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1783,8 +1788,7 @@ const deserializeAws_restJson1CreateNodegroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1809,10 +1813,12 @@ const deserializeAws_restJson1CreateNodegroupCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1845,8 +1851,7 @@ const deserializeAws_restJson1DeleteAddonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1865,10 +1870,12 @@ const deserializeAws_restJson1DeleteAddonCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1901,8 +1908,7 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1921,10 +1927,12 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1957,8 +1965,7 @@ const deserializeAws_restJson1DeleteFargateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -1974,10 +1981,12 @@ const deserializeAws_restJson1DeleteFargateProfileCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2010,8 +2019,7 @@ const deserializeAws_restJson1DeleteNodegroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2033,10 +2041,12 @@ const deserializeAws_restJson1DeleteNodegroupCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2069,8 +2079,7 @@ const deserializeAws_restJson1DeregisterClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.eks#AccessDeniedException": @@ -2092,10 +2101,12 @@ const deserializeAws_restJson1DeregisterClusterCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2128,8 +2139,7 @@ const deserializeAws_restJson1DescribeAddonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2148,10 +2158,12 @@ const deserializeAws_restJson1DescribeAddonCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2188,8 +2200,7 @@ const deserializeAws_restJson1DescribeAddonVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.eks#InvalidParameterException": @@ -2202,10 +2213,12 @@ const deserializeAws_restJson1DescribeAddonVersionsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2238,8 +2251,7 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2255,10 +2267,12 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2291,8 +2305,7 @@ const deserializeAws_restJson1DescribeFargateProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2308,10 +2321,12 @@ const deserializeAws_restJson1DescribeFargateProfileCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2347,8 +2362,7 @@ const deserializeAws_restJson1DescribeIdentityProviderConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2367,10 +2381,12 @@ const deserializeAws_restJson1DescribeIdentityProviderConfigCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2403,8 +2419,7 @@ const deserializeAws_restJson1DescribeNodegroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2423,10 +2438,12 @@ const deserializeAws_restJson1DescribeNodegroupCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2459,8 +2476,7 @@ const deserializeAws_restJson1DescribeUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2476,10 +2492,12 @@ const deserializeAws_restJson1DescribeUpdateCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2512,8 +2530,7 @@ const deserializeAws_restJson1DisassociateIdentityProviderConfigCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2535,10 +2552,12 @@ const deserializeAws_restJson1DisassociateIdentityProviderConfigCommandError = a throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2575,8 +2594,7 @@ const deserializeAws_restJson1ListAddonsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2595,10 +2613,12 @@ const deserializeAws_restJson1ListAddonsCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2635,8 +2655,7 @@ const deserializeAws_restJson1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2652,10 +2671,12 @@ const deserializeAws_restJson1ListClustersCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2692,8 +2713,7 @@ const deserializeAws_restJson1ListFargateProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2709,10 +2729,12 @@ const deserializeAws_restJson1ListFargateProfilesCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2752,8 +2774,7 @@ const deserializeAws_restJson1ListIdentityProviderConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2772,10 +2793,12 @@ const deserializeAws_restJson1ListIdentityProviderConfigsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2812,8 +2835,7 @@ const deserializeAws_restJson1ListNodegroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2832,10 +2854,12 @@ const deserializeAws_restJson1ListNodegroupsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2868,8 +2892,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.eks#BadRequestException": @@ -2879,10 +2902,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2919,8 +2944,7 @@ const deserializeAws_restJson1ListUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -2936,10 +2960,12 @@ const deserializeAws_restJson1ListUpdatesCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2972,8 +2998,7 @@ const deserializeAws_restJson1RegisterClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.eks#AccessDeniedException": @@ -3001,10 +3026,12 @@ const deserializeAws_restJson1RegisterClusterCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3033,8 +3060,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.eks#BadRequestException": @@ -3044,10 +3070,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3076,8 +3104,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.eks#BadRequestException": @@ -3087,10 +3114,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3123,8 +3152,7 @@ const deserializeAws_restJson1UpdateAddonCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -3146,10 +3174,12 @@ const deserializeAws_restJson1UpdateAddonCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3182,8 +3212,7 @@ const deserializeAws_restJson1UpdateClusterConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -3205,10 +3234,12 @@ const deserializeAws_restJson1UpdateClusterConfigCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3241,8 +3272,7 @@ const deserializeAws_restJson1UpdateClusterVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -3264,10 +3294,12 @@ const deserializeAws_restJson1UpdateClusterVersionCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3300,8 +3332,7 @@ const deserializeAws_restJson1UpdateNodegroupConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -3323,10 +3354,12 @@ const deserializeAws_restJson1UpdateNodegroupConfigCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3359,8 +3392,7 @@ const deserializeAws_restJson1UpdateNodegroupVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.eks#ClientException": @@ -3382,10 +3414,12 @@ const deserializeAws_restJson1UpdateNodegroupVersionCommandError = async ( throw await deserializeAws_restJson1ServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4762,7 +4796,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4788,6 +4822,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-elastic-beanstalk/src/protocols/Aws_query.ts b/clients/client-elastic-beanstalk/src/protocols/Aws_query.ts index 5b42abd1e142b..1fc760b32921c 100644 --- a/clients/client-elastic-beanstalk/src/protocols/Aws_query.ts +++ b/clients/client-elastic-beanstalk/src/protocols/Aws_query.ts @@ -1106,18 +1106,19 @@ const deserializeAws_queryAbortEnvironmentUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1149,8 +1150,7 @@ const deserializeAws_queryApplyEnvironmentManagedActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -1160,10 +1160,12 @@ const deserializeAws_queryApplyEnvironmentManagedActionCommandError = async ( throw await deserializeAws_queryManagedActionInvalidStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1192,18 +1194,19 @@ const deserializeAws_queryAssociateEnvironmentOperationsRoleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1235,15 +1238,16 @@ const deserializeAws_queryCheckDNSAvailabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1275,8 +1279,7 @@ const deserializeAws_queryComposeEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -1286,10 +1289,12 @@ const deserializeAws_queryComposeEnvironmentsCommandError = async ( throw await deserializeAws_queryTooManyEnvironmentsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1321,18 +1326,19 @@ const deserializeAws_queryCreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TooManyApplicationsException": case "com.amazonaws.elasticbeanstalk#TooManyApplicationsException": throw await deserializeAws_queryTooManyApplicationsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1364,8 +1370,7 @@ const deserializeAws_queryCreateApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeBuildNotInServiceRegionException": case "com.amazonaws.elasticbeanstalk#CodeBuildNotInServiceRegionException": @@ -1384,10 +1389,12 @@ const deserializeAws_queryCreateApplicationVersionCommandError = async ( throw await deserializeAws_queryTooManyApplicationVersionsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1419,8 +1426,7 @@ const deserializeAws_queryCreateConfigurationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -1433,10 +1439,12 @@ const deserializeAws_queryCreateConfigurationTemplateCommandError = async ( throw await deserializeAws_queryTooManyConfigurationTemplatesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1468,8 +1476,7 @@ const deserializeAws_queryCreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -1479,10 +1486,12 @@ const deserializeAws_queryCreateEnvironmentCommandError = async ( throw await deserializeAws_queryTooManyEnvironmentsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1514,8 +1523,7 @@ const deserializeAws_queryCreatePlatformVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -1528,10 +1536,12 @@ const deserializeAws_queryCreatePlatformVersionCommandError = async ( throw await deserializeAws_queryTooManyPlatformsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1563,8 +1573,7 @@ const deserializeAws_queryCreateStorageLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -1577,10 +1586,12 @@ const deserializeAws_queryCreateStorageLocationCommandError = async ( throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1609,18 +1620,19 @@ const deserializeAws_queryDeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationInProgressException": case "com.amazonaws.elasticbeanstalk#OperationInProgressException": throw await deserializeAws_queryOperationInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1649,8 +1661,7 @@ const deserializeAws_queryDeleteApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -1666,10 +1677,12 @@ const deserializeAws_queryDeleteApplicationVersionCommandError = async ( throw await deserializeAws_querySourceBundleDeletionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1698,18 +1711,19 @@ const deserializeAws_queryDeleteConfigurationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationInProgressException": case "com.amazonaws.elasticbeanstalk#OperationInProgressException": throw await deserializeAws_queryOperationInProgressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1738,15 +1752,16 @@ const deserializeAws_queryDeleteEnvironmentConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1778,8 +1793,7 @@ const deserializeAws_queryDeletePlatformVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -1795,10 +1809,12 @@ const deserializeAws_queryDeletePlatformVersionCommandError = async ( throw await deserializeAws_queryPlatformVersionStillReferencedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1830,18 +1846,19 @@ const deserializeAws_queryDescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1873,15 +1890,16 @@ const deserializeAws_queryDescribeApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1913,15 +1931,16 @@ const deserializeAws_queryDescribeApplicationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1953,18 +1972,19 @@ const deserializeAws_queryDescribeConfigurationOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TooManyBucketsException": case "com.amazonaws.elasticbeanstalk#TooManyBucketsException": throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1996,18 +2016,19 @@ const deserializeAws_queryDescribeConfigurationSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TooManyBucketsException": case "com.amazonaws.elasticbeanstalk#TooManyBucketsException": throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2039,8 +2060,7 @@ const deserializeAws_queryDescribeEnvironmentHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -2050,10 +2070,12 @@ const deserializeAws_queryDescribeEnvironmentHealthCommandError = async ( throw await deserializeAws_queryInvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2088,18 +2110,19 @@ const deserializeAws_queryDescribeEnvironmentManagedActionHistoryCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": throw await deserializeAws_queryElasticBeanstalkServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2134,18 +2157,19 @@ const deserializeAws_queryDescribeEnvironmentManagedActionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": throw await deserializeAws_queryElasticBeanstalkServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2180,18 +2204,19 @@ const deserializeAws_queryDescribeEnvironmentResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2223,15 +2248,16 @@ const deserializeAws_queryDescribeEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2263,15 +2289,16 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2303,8 +2330,7 @@ const deserializeAws_queryDescribeInstancesHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -2314,10 +2340,12 @@ const deserializeAws_queryDescribeInstancesHealthCommandError = async ( throw await deserializeAws_queryInvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2349,8 +2377,7 @@ const deserializeAws_queryDescribePlatformVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -2360,10 +2387,12 @@ const deserializeAws_queryDescribePlatformVersionCommandError = async ( throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2392,18 +2421,19 @@ const deserializeAws_queryDisassociateEnvironmentOperationsRoleCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2438,15 +2468,16 @@ const deserializeAws_queryListAvailableSolutionStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2478,15 +2509,16 @@ const deserializeAws_queryListPlatformBranchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2518,8 +2550,7 @@ const deserializeAws_queryListPlatformVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ElasticBeanstalkServiceException": case "com.amazonaws.elasticbeanstalk#ElasticBeanstalkServiceException": @@ -2529,10 +2560,12 @@ const deserializeAws_queryListPlatformVersionsCommandError = async ( throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2564,8 +2597,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -2578,10 +2610,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryResourceTypeNotSupportedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2610,18 +2644,19 @@ const deserializeAws_queryRebuildEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2650,15 +2685,16 @@ const deserializeAws_queryRequestEnvironmentInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2687,15 +2723,16 @@ const deserializeAws_queryRestartAppServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2727,15 +2764,16 @@ const deserializeAws_queryRetrieveEnvironmentInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2764,15 +2802,16 @@ const deserializeAws_querySwapEnvironmentCNAMEsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2804,18 +2843,19 @@ const deserializeAws_queryTerminateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2847,15 +2887,16 @@ const deserializeAws_queryUpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2890,18 +2931,19 @@ const deserializeAws_queryUpdateApplicationResourceLifecycleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": throw await deserializeAws_queryInsufficientPrivilegesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2933,15 +2975,16 @@ const deserializeAws_queryUpdateApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2973,8 +3016,7 @@ const deserializeAws_queryUpdateConfigurationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -2984,10 +3026,12 @@ const deserializeAws_queryUpdateConfigurationTemplateCommandError = async ( throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3019,8 +3063,7 @@ const deserializeAws_queryUpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -3030,10 +3073,12 @@ const deserializeAws_queryUpdateEnvironmentCommandError = async ( throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3062,8 +3107,7 @@ const deserializeAws_queryUpdateTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -3082,10 +3126,12 @@ const deserializeAws_queryUpdateTagsForResourceCommandError = async ( throw await deserializeAws_queryTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3120,8 +3166,7 @@ const deserializeAws_queryValidateConfigurationSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientPrivilegesException": case "com.amazonaws.elasticbeanstalk#InsufficientPrivilegesException": @@ -3131,10 +3176,12 @@ const deserializeAws_queryValidateConfigurationSettingsCommandError = async ( throw await deserializeAws_queryTooManyBucketsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7548,12 +7595,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-elastic-inference/src/protocols/Aws_restJson1.ts b/clients/client-elastic-inference/src/protocols/Aws_restJson1.ts index 35c599d43a460..8bc260d69234b 100644 --- a/clients/client-elastic-inference/src/protocols/Aws_restJson1.ts +++ b/clients/client-elastic-inference/src/protocols/Aws_restJson1.ts @@ -252,8 +252,7 @@ const deserializeAws_restJson1DescribeAcceleratorOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.elasticinference#BadRequestException": @@ -266,10 +265,12 @@ const deserializeAws_restJson1DescribeAcceleratorOfferingsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -306,8 +307,7 @@ const deserializeAws_restJson1DescribeAcceleratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.elasticinference#BadRequestException": @@ -320,10 +320,12 @@ const deserializeAws_restJson1DescribeAcceleratorsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -356,18 +358,19 @@ const deserializeAws_restJson1DescribeAcceleratorTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.elasticinference#InternalServerException": throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -400,8 +403,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.elasticinference#BadRequestException": @@ -414,10 +416,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -446,8 +450,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.elasticinference#BadRequestException": @@ -460,10 +463,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -492,8 +497,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.elasticinference#BadRequestException": @@ -506,10 +510,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -793,7 +799,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -819,6 +825,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-elastic-load-balancing-v2/src/protocols/Aws_query.ts b/clients/client-elastic-load-balancing-v2/src/protocols/Aws_query.ts index 03a2ead5a5673..a85cd19978ffc 100644 --- a/clients/client-elastic-load-balancing-v2/src/protocols/Aws_query.ts +++ b/clients/client-elastic-load-balancing-v2/src/protocols/Aws_query.ts @@ -807,8 +807,7 @@ const deserializeAws_queryAddListenerCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateNotFoundException": case "com.amazonaws.elasticloadbalancingv2#CertificateNotFoundException": @@ -821,10 +820,12 @@ const deserializeAws_queryAddListenerCertificatesCommandError = async ( throw await deserializeAws_queryTooManyCertificatesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -856,8 +857,7 @@ const deserializeAws_queryAddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateTagKeysException": case "com.amazonaws.elasticloadbalancingv2#DuplicateTagKeysException": @@ -879,10 +879,12 @@ const deserializeAws_queryAddTagsCommandError = async ( throw await deserializeAws_queryTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -914,8 +916,7 @@ const deserializeAws_queryCreateListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ALPNPolicyNotSupportedException": case "com.amazonaws.elasticloadbalancingv2#ALPNPolicyNotSupportedException": @@ -973,10 +974,12 @@ const deserializeAws_queryCreateListenerCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1008,8 +1011,7 @@ const deserializeAws_queryCreateLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AllocationIdNotFoundException": case "com.amazonaws.elasticloadbalancingv2#AllocationIdNotFoundException": @@ -1052,10 +1054,12 @@ const deserializeAws_queryCreateLoadBalancerCommandError = async ( throw await deserializeAws_queryTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1087,8 +1091,7 @@ const deserializeAws_queryCreateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "IncompatibleProtocolsException": case "com.amazonaws.elasticloadbalancingv2#IncompatibleProtocolsException": @@ -1137,10 +1140,12 @@ const deserializeAws_queryCreateRuleCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1172,8 +1177,7 @@ const deserializeAws_queryCreateTargetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateTargetGroupNameException": case "com.amazonaws.elasticloadbalancingv2#DuplicateTargetGroupNameException": @@ -1189,10 +1193,12 @@ const deserializeAws_queryCreateTargetGroupCommandError = async ( throw await deserializeAws_queryTooManyTargetGroupsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1224,8 +1230,7 @@ const deserializeAws_queryDeleteListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -1235,10 +1240,12 @@ const deserializeAws_queryDeleteListenerCommandError = async ( throw await deserializeAws_queryResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1270,8 +1277,7 @@ const deserializeAws_queryDeleteLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LoadBalancerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#LoadBalancerNotFoundException": @@ -1284,10 +1290,12 @@ const deserializeAws_queryDeleteLoadBalancerCommandError = async ( throw await deserializeAws_queryResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1319,8 +1327,7 @@ const deserializeAws_queryDeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.elasticloadbalancingv2#OperationNotPermittedException": @@ -1330,10 +1337,12 @@ const deserializeAws_queryDeleteRuleCommandError = async ( throw await deserializeAws_queryRuleNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1365,18 +1374,19 @@ const deserializeAws_queryDeleteTargetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.elasticloadbalancingv2#ResourceInUseException": throw await deserializeAws_queryResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1408,8 +1418,7 @@ const deserializeAws_queryDeregisterTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTargetException": case "com.amazonaws.elasticloadbalancingv2#InvalidTargetException": @@ -1419,10 +1428,12 @@ const deserializeAws_queryDeregisterTargetsCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1454,15 +1465,16 @@ const deserializeAws_queryDescribeAccountLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1494,18 +1506,19 @@ const deserializeAws_queryDescribeListenerCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": throw await deserializeAws_queryListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1537,8 +1550,7 @@ const deserializeAws_queryDescribeListenersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -1551,10 +1563,12 @@ const deserializeAws_queryDescribeListenersCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1589,18 +1603,19 @@ const deserializeAws_queryDescribeLoadBalancerAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LoadBalancerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#LoadBalancerNotFoundException": throw await deserializeAws_queryLoadBalancerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1632,18 +1647,19 @@ const deserializeAws_queryDescribeLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LoadBalancerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#LoadBalancerNotFoundException": throw await deserializeAws_queryLoadBalancerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1675,8 +1691,7 @@ const deserializeAws_queryDescribeRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -1689,10 +1704,12 @@ const deserializeAws_queryDescribeRulesCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1724,18 +1741,19 @@ const deserializeAws_queryDescribeSSLPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SSLPolicyNotFoundException": case "com.amazonaws.elasticloadbalancingv2#SSLPolicyNotFoundException": throw await deserializeAws_querySSLPolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1767,8 +1785,7 @@ const deserializeAws_queryDescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -1784,10 +1801,12 @@ const deserializeAws_queryDescribeTagsCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1819,18 +1838,19 @@ const deserializeAws_queryDescribeTargetGroupAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TargetGroupNotFoundException": case "com.amazonaws.elasticloadbalancingv2#TargetGroupNotFoundException": throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1862,8 +1882,7 @@ const deserializeAws_queryDescribeTargetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LoadBalancerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#LoadBalancerNotFoundException": @@ -1873,10 +1892,12 @@ const deserializeAws_queryDescribeTargetGroupsCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1908,8 +1929,7 @@ const deserializeAws_queryDescribeTargetHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HealthUnavailableException": case "com.amazonaws.elasticloadbalancingv2#HealthUnavailableException": @@ -1922,10 +1942,12 @@ const deserializeAws_queryDescribeTargetHealthCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1957,8 +1979,7 @@ const deserializeAws_queryModifyListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ALPNPolicyNotSupportedException": case "com.amazonaws.elasticloadbalancingv2#ALPNPolicyNotSupportedException": @@ -2013,10 +2034,12 @@ const deserializeAws_queryModifyListenerCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2048,8 +2071,7 @@ const deserializeAws_queryModifyLoadBalancerAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRequestException": case "com.amazonaws.elasticloadbalancingv2#InvalidConfigurationRequestException": @@ -2059,10 +2081,12 @@ const deserializeAws_queryModifyLoadBalancerAttributesCommandError = async ( throw await deserializeAws_queryLoadBalancerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2094,8 +2118,7 @@ const deserializeAws_queryModifyRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "IncompatibleProtocolsException": case "com.amazonaws.elasticloadbalancingv2#IncompatibleProtocolsException": @@ -2132,10 +2155,12 @@ const deserializeAws_queryModifyRuleCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2167,8 +2192,7 @@ const deserializeAws_queryModifyTargetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRequestException": case "com.amazonaws.elasticloadbalancingv2#InvalidConfigurationRequestException": @@ -2178,10 +2202,12 @@ const deserializeAws_queryModifyTargetGroupCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2213,8 +2239,7 @@ const deserializeAws_queryModifyTargetGroupAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRequestException": case "com.amazonaws.elasticloadbalancingv2#InvalidConfigurationRequestException": @@ -2224,10 +2249,12 @@ const deserializeAws_queryModifyTargetGroupAttributesCommandError = async ( throw await deserializeAws_queryTargetGroupNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2259,8 +2286,7 @@ const deserializeAws_queryRegisterTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTargetException": case "com.amazonaws.elasticloadbalancingv2#InvalidTargetException": @@ -2276,10 +2302,12 @@ const deserializeAws_queryRegisterTargetsCommandError = async ( throw await deserializeAws_queryTooManyTargetsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2311,8 +2339,7 @@ const deserializeAws_queryRemoveListenerCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -2322,10 +2349,12 @@ const deserializeAws_queryRemoveListenerCertificatesCommandError = async ( throw await deserializeAws_queryOperationNotPermittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2357,8 +2386,7 @@ const deserializeAws_queryRemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ListenerNotFoundException": case "com.amazonaws.elasticloadbalancingv2#ListenerNotFoundException": @@ -2377,10 +2405,12 @@ const deserializeAws_queryRemoveTagsCommandError = async ( throw await deserializeAws_queryTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2412,8 +2442,7 @@ const deserializeAws_querySetIpAddressTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRequestException": case "com.amazonaws.elasticloadbalancingv2#InvalidConfigurationRequestException": @@ -2426,10 +2455,12 @@ const deserializeAws_querySetIpAddressTypeCommandError = async ( throw await deserializeAws_queryLoadBalancerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2461,8 +2492,7 @@ const deserializeAws_querySetRulePrioritiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.elasticloadbalancingv2#OperationNotPermittedException": @@ -2475,10 +2505,12 @@ const deserializeAws_querySetRulePrioritiesCommandError = async ( throw await deserializeAws_queryRuleNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2510,8 +2542,7 @@ const deserializeAws_querySetSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidConfigurationRequestException": case "com.amazonaws.elasticloadbalancingv2#InvalidConfigurationRequestException": @@ -2524,10 +2555,12 @@ const deserializeAws_querySetSecurityGroupsCommandError = async ( throw await deserializeAws_queryLoadBalancerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2559,8 +2592,7 @@ const deserializeAws_querySetSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AllocationIdNotFoundException": case "com.amazonaws.elasticloadbalancingv2#AllocationIdNotFoundException": @@ -2582,10 +2614,12 @@ const deserializeAws_querySetSubnetsCommandError = async ( throw await deserializeAws_querySubnetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6868,12 +6902,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-elastic-load-balancing/src/protocols/Aws_query.ts b/clients/client-elastic-load-balancing/src/protocols/Aws_query.ts index ac5f725bae86a..e765d37b30fe9 100644 --- a/clients/client-elastic-load-balancing/src/protocols/Aws_query.ts +++ b/clients/client-elastic-load-balancing/src/protocols/Aws_query.ts @@ -722,8 +722,7 @@ const deserializeAws_queryAddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -736,10 +735,12 @@ const deserializeAws_queryAddTagsCommandError = async ( throw await deserializeAws_queryTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -774,8 +775,7 @@ const deserializeAws_queryApplySecurityGroupsToLoadBalancerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -788,10 +788,12 @@ const deserializeAws_queryApplySecurityGroupsToLoadBalancerCommandError = async throw await deserializeAws_queryInvalidSecurityGroupExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -823,8 +825,7 @@ const deserializeAws_queryAttachLoadBalancerToSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -840,10 +841,12 @@ const deserializeAws_queryAttachLoadBalancerToSubnetsCommandError = async ( throw await deserializeAws_querySubnetNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -875,18 +878,19 @@ const deserializeAws_queryConfigureHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": throw await deserializeAws_queryAccessPointNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -921,8 +925,7 @@ const deserializeAws_queryCreateAppCookieStickinessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -938,10 +941,12 @@ const deserializeAws_queryCreateAppCookieStickinessPolicyCommandError = async ( throw await deserializeAws_queryTooManyPoliciesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -976,8 +981,7 @@ const deserializeAws_queryCreateLBCookieStickinessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -993,10 +997,12 @@ const deserializeAws_queryCreateLBCookieStickinessPolicyCommandError = async ( throw await deserializeAws_queryTooManyPoliciesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1028,8 +1034,7 @@ const deserializeAws_queryCreateLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateNotFoundException": case "com.amazonaws.elasticloadbalancing#CertificateNotFoundException": @@ -1069,10 +1074,12 @@ const deserializeAws_queryCreateLoadBalancerCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1104,8 +1111,7 @@ const deserializeAws_queryCreateLoadBalancerListenersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1124,10 +1130,12 @@ const deserializeAws_queryCreateLoadBalancerListenersCommandError = async ( throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1159,8 +1167,7 @@ const deserializeAws_queryCreateLoadBalancerPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1179,10 +1186,12 @@ const deserializeAws_queryCreateLoadBalancerPolicyCommandError = async ( throw await deserializeAws_queryTooManyPoliciesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1214,15 +1223,16 @@ const deserializeAws_queryDeleteLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1254,18 +1264,19 @@ const deserializeAws_queryDeleteLoadBalancerListenersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": throw await deserializeAws_queryAccessPointNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1297,8 +1308,7 @@ const deserializeAws_queryDeleteLoadBalancerPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1308,10 +1318,12 @@ const deserializeAws_queryDeleteLoadBalancerPolicyCommandError = async ( throw await deserializeAws_queryInvalidConfigurationRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1343,8 +1355,7 @@ const deserializeAws_queryDeregisterInstancesFromLoadBalancerCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1354,10 +1365,12 @@ const deserializeAws_queryDeregisterInstancesFromLoadBalancerCommandError = asyn throw await deserializeAws_queryInvalidEndPointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1389,15 +1402,16 @@ const deserializeAws_queryDescribeAccountLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1429,8 +1443,7 @@ const deserializeAws_queryDescribeInstanceHealthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1440,10 +1453,12 @@ const deserializeAws_queryDescribeInstanceHealthCommandError = async ( throw await deserializeAws_queryInvalidEndPointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1478,8 +1493,7 @@ const deserializeAws_queryDescribeLoadBalancerAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1489,10 +1503,12 @@ const deserializeAws_queryDescribeLoadBalancerAttributesCommandError = async ( throw await deserializeAws_queryLoadBalancerAttributeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1524,8 +1540,7 @@ const deserializeAws_queryDescribeLoadBalancerPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1535,10 +1550,12 @@ const deserializeAws_queryDescribeLoadBalancerPoliciesCommandError = async ( throw await deserializeAws_queryPolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1573,18 +1590,19 @@ const deserializeAws_queryDescribeLoadBalancerPolicyTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "PolicyTypeNotFoundException": case "com.amazonaws.elasticloadbalancing#PolicyTypeNotFoundException": throw await deserializeAws_queryPolicyTypeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1616,8 +1634,7 @@ const deserializeAws_queryDescribeLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1627,10 +1644,12 @@ const deserializeAws_queryDescribeLoadBalancersCommandError = async ( throw await deserializeAws_queryDependencyThrottleExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1662,18 +1681,19 @@ const deserializeAws_queryDescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": throw await deserializeAws_queryAccessPointNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1705,8 +1725,7 @@ const deserializeAws_queryDetachLoadBalancerFromSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1716,10 +1735,12 @@ const deserializeAws_queryDetachLoadBalancerFromSubnetsCommandError = async ( throw await deserializeAws_queryInvalidConfigurationRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1754,8 +1775,7 @@ const deserializeAws_queryDisableAvailabilityZonesForLoadBalancerCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1765,10 +1785,12 @@ const deserializeAws_queryDisableAvailabilityZonesForLoadBalancerCommandError = throw await deserializeAws_queryInvalidConfigurationRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1800,18 +1822,19 @@ const deserializeAws_queryEnableAvailabilityZonesForLoadBalancerCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": throw await deserializeAws_queryAccessPointNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1843,8 +1866,7 @@ const deserializeAws_queryModifyLoadBalancerAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1857,10 +1879,12 @@ const deserializeAws_queryModifyLoadBalancerAttributesCommandError = async ( throw await deserializeAws_queryLoadBalancerAttributeNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1892,8 +1916,7 @@ const deserializeAws_queryRegisterInstancesWithLoadBalancerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -1903,10 +1926,12 @@ const deserializeAws_queryRegisterInstancesWithLoadBalancerCommandError = async throw await deserializeAws_queryInvalidEndPointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1938,18 +1963,19 @@ const deserializeAws_queryRemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": throw await deserializeAws_queryAccessPointNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1984,8 +2010,7 @@ const deserializeAws_querySetLoadBalancerListenerSSLCertificateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -2004,10 +2029,12 @@ const deserializeAws_querySetLoadBalancerListenerSSLCertificateCommandError = as throw await deserializeAws_queryUnsupportedProtocolExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2042,8 +2069,7 @@ const deserializeAws_querySetLoadBalancerPoliciesForBackendServerCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -2056,10 +2082,12 @@ const deserializeAws_querySetLoadBalancerPoliciesForBackendServerCommandError = throw await deserializeAws_queryPolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2094,8 +2122,7 @@ const deserializeAws_querySetLoadBalancerPoliciesOfListenerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessPointNotFoundException": case "com.amazonaws.elasticloadbalancing#AccessPointNotFoundException": @@ -2111,10 +2138,12 @@ const deserializeAws_querySetLoadBalancerPoliciesOfListenerCommandError = async throw await deserializeAws_queryPolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4800,12 +4829,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-elastic-transcoder/src/protocols/Aws_restJson1.ts b/clients/client-elastic-transcoder/src/protocols/Aws_restJson1.ts index 69e9124317796..438bfcf295496 100644 --- a/clients/client-elastic-transcoder/src/protocols/Aws_restJson1.ts +++ b/clients/client-elastic-transcoder/src/protocols/Aws_restJson1.ts @@ -647,8 +647,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -670,10 +669,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -706,8 +707,7 @@ const deserializeAws_restJson1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -729,10 +729,12 @@ const deserializeAws_restJson1CreateJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -769,8 +771,7 @@ const deserializeAws_restJson1CreatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -792,10 +793,12 @@ const deserializeAws_restJson1CreatePipelineCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -832,8 +835,7 @@ const deserializeAws_restJson1CreatePresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -852,10 +854,12 @@ const deserializeAws_restJson1CreatePresetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -884,8 +888,7 @@ const deserializeAws_restJson1DeletePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -907,10 +910,12 @@ const deserializeAws_restJson1DeletePipelineCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -939,8 +944,7 @@ const deserializeAws_restJson1DeletePresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -959,10 +963,12 @@ const deserializeAws_restJson1DeletePresetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -999,8 +1005,7 @@ const deserializeAws_restJson1ListJobsByPipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1019,10 +1024,12 @@ const deserializeAws_restJson1ListJobsByPipelineCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1059,8 +1066,7 @@ const deserializeAws_restJson1ListJobsByStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1079,10 +1085,12 @@ const deserializeAws_restJson1ListJobsByStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1119,8 +1127,7 @@ const deserializeAws_restJson1ListPipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1136,10 +1143,12 @@ const deserializeAws_restJson1ListPipelinesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1176,8 +1185,7 @@ const deserializeAws_restJson1ListPresetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1193,10 +1201,12 @@ const deserializeAws_restJson1ListPresetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1229,8 +1239,7 @@ const deserializeAws_restJson1ReadJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1249,10 +1258,12 @@ const deserializeAws_restJson1ReadJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1289,8 +1300,7 @@ const deserializeAws_restJson1ReadPipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1309,10 +1319,12 @@ const deserializeAws_restJson1ReadPipelineCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1345,8 +1357,7 @@ const deserializeAws_restJson1ReadPresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1365,10 +1376,12 @@ const deserializeAws_restJson1ReadPresetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1405,8 +1418,7 @@ const deserializeAws_restJson1TestRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1425,10 +1437,12 @@ const deserializeAws_restJson1TestRoleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1465,8 +1479,7 @@ const deserializeAws_restJson1UpdatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1488,10 +1501,12 @@ const deserializeAws_restJson1UpdatePipelineCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1524,8 +1539,7 @@ const deserializeAws_restJson1UpdatePipelineNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1547,10 +1561,12 @@ const deserializeAws_restJson1UpdatePipelineNotificationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1583,8 +1599,7 @@ const deserializeAws_restJson1UpdatePipelineStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elastictranscoder#AccessDeniedException": @@ -1606,10 +1621,12 @@ const deserializeAws_restJson1UpdatePipelineStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2909,7 +2926,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2935,6 +2952,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-elasticache/src/protocols/Aws_query.ts b/clients/client-elasticache/src/protocols/Aws_query.ts index e9105afed6db8..42d4d5e960cd1 100644 --- a/clients/client-elasticache/src/protocols/Aws_query.ts +++ b/clients/client-elasticache/src/protocols/Aws_query.ts @@ -1537,8 +1537,7 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -1578,10 +1577,12 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1616,8 +1617,7 @@ const deserializeAws_queryAuthorizeCacheSecurityGroupIngressCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationAlreadyExistsFault": case "com.amazonaws.elasticache#AuthorizationAlreadyExistsFault": @@ -1636,10 +1636,12 @@ const deserializeAws_queryAuthorizeCacheSecurityGroupIngressCommandError = async throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1671,8 +1673,7 @@ const deserializeAws_queryBatchApplyUpdateActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.elasticache#InvalidParameterValueException": @@ -1682,10 +1683,12 @@ const deserializeAws_queryBatchApplyUpdateActionCommandError = async ( throw await deserializeAws_queryServiceUpdateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1717,8 +1720,7 @@ const deserializeAws_queryBatchStopUpdateActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.elasticache#InvalidParameterValueException": @@ -1728,10 +1730,12 @@ const deserializeAws_queryBatchStopUpdateActionCommandError = async ( throw await deserializeAws_queryServiceUpdateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1763,8 +1767,7 @@ const deserializeAws_queryCompleteMigrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidReplicationGroupStateFault": case "com.amazonaws.elasticache#InvalidReplicationGroupStateFault": @@ -1777,10 +1780,12 @@ const deserializeAws_queryCompleteMigrationCommandError = async ( throw await deserializeAws_queryReplicationGroupNotUnderMigrationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1812,8 +1817,7 @@ const deserializeAws_queryCopySnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -1838,10 +1842,12 @@ const deserializeAws_queryCopySnapshotCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1873,8 +1879,7 @@ const deserializeAws_queryCreateCacheClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterAlreadyExistsFault": case "com.amazonaws.elasticache#CacheClusterAlreadyExistsFault": @@ -1920,10 +1925,12 @@ const deserializeAws_queryCreateCacheClusterCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1955,8 +1962,7 @@ const deserializeAws_queryCreateCacheParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupAlreadyExistsFault": case "com.amazonaws.elasticache#CacheParameterGroupAlreadyExistsFault": @@ -1978,10 +1984,12 @@ const deserializeAws_queryCreateCacheParameterGroupCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2013,8 +2021,7 @@ const deserializeAws_queryCreateCacheSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSecurityGroupAlreadyExistsFault": case "com.amazonaws.elasticache#CacheSecurityGroupAlreadyExistsFault": @@ -2033,10 +2040,12 @@ const deserializeAws_queryCreateCacheSecurityGroupCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2068,8 +2077,7 @@ const deserializeAws_queryCreateCacheSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSubnetGroupAlreadyExistsFault": case "com.amazonaws.elasticache#CacheSubnetGroupAlreadyExistsFault": @@ -2091,10 +2099,12 @@ const deserializeAws_queryCreateCacheSubnetGroupCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2126,8 +2136,7 @@ const deserializeAws_queryCreateGlobalReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupAlreadyExistsFault": case "com.amazonaws.elasticache#GlobalReplicationGroupAlreadyExistsFault": @@ -2146,10 +2155,12 @@ const deserializeAws_queryCreateGlobalReplicationGroupCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2181,8 +2192,7 @@ const deserializeAws_queryCreateReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -2243,10 +2253,12 @@ const deserializeAws_queryCreateReplicationGroupCommandError = async ( throw await deserializeAws_queryUserGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2278,8 +2290,7 @@ const deserializeAws_queryCreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -2313,10 +2324,12 @@ const deserializeAws_queryCreateSnapshotCommandError = async ( throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2348,8 +2361,7 @@ const deserializeAws_queryCreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateUserNameFault": case "com.amazonaws.elasticache#DuplicateUserNameFault": @@ -2374,10 +2386,12 @@ const deserializeAws_queryCreateUserCommandError = async ( throw await deserializeAws_queryUserQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2409,8 +2423,7 @@ const deserializeAws_queryCreateUserGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DefaultUserRequired": case "com.amazonaws.elasticache#DefaultUserRequired": @@ -2438,10 +2451,12 @@ const deserializeAws_queryCreateUserGroupCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2476,8 +2491,7 @@ const deserializeAws_queryDecreaseNodeGroupsInGlobalReplicationGroupCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -2493,10 +2507,12 @@ const deserializeAws_queryDecreaseNodeGroupsInGlobalReplicationGroupCommandError throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2528,8 +2544,7 @@ const deserializeAws_queryDecreaseReplicaCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterQuotaForCustomerExceededFault": case "com.amazonaws.elasticache#ClusterQuotaForCustomerExceededFault": @@ -2569,10 +2584,12 @@ const deserializeAws_queryDecreaseReplicaCountCommandError = async ( throw await deserializeAws_queryServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2604,8 +2621,7 @@ const deserializeAws_queryDeleteCacheClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -2630,10 +2646,12 @@ const deserializeAws_queryDeleteCacheClusterCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2662,8 +2680,7 @@ const deserializeAws_queryDeleteCacheParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupNotFoundFault": case "com.amazonaws.elasticache#CacheParameterGroupNotFoundFault": @@ -2679,10 +2696,12 @@ const deserializeAws_queryDeleteCacheParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2711,8 +2730,7 @@ const deserializeAws_queryDeleteCacheSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSecurityGroupNotFoundFault": case "com.amazonaws.elasticache#CacheSecurityGroupNotFoundFault": @@ -2728,10 +2746,12 @@ const deserializeAws_queryDeleteCacheSecurityGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2760,8 +2780,7 @@ const deserializeAws_queryDeleteCacheSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSubnetGroupInUse": case "com.amazonaws.elasticache#CacheSubnetGroupInUse": @@ -2771,10 +2790,12 @@ const deserializeAws_queryDeleteCacheSubnetGroupCommandError = async ( throw await deserializeAws_queryCacheSubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2806,8 +2827,7 @@ const deserializeAws_queryDeleteGlobalReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -2820,10 +2840,12 @@ const deserializeAws_queryDeleteGlobalReplicationGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2855,8 +2877,7 @@ const deserializeAws_queryDeleteReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -2881,10 +2902,12 @@ const deserializeAws_queryDeleteReplicationGroupCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2916,8 +2939,7 @@ const deserializeAws_queryDeleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -2933,10 +2955,12 @@ const deserializeAws_queryDeleteSnapshotCommandError = async ( throw await deserializeAws_querySnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2968,8 +2992,7 @@ const deserializeAws_queryDeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DefaultUserAssociatedToUserGroupFault": case "com.amazonaws.elasticache#DefaultUserAssociatedToUserGroupFault": @@ -2988,10 +3011,12 @@ const deserializeAws_queryDeleteUserCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3023,8 +3048,7 @@ const deserializeAws_queryDeleteUserGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.elasticache#InvalidParameterValueException": @@ -3040,10 +3064,12 @@ const deserializeAws_queryDeleteUserGroupCommandError = async ( throw await deserializeAws_queryUserGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3075,8 +3101,7 @@ const deserializeAws_queryDescribeCacheClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -3089,10 +3114,12 @@ const deserializeAws_queryDescribeCacheClustersCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3124,15 +3151,16 @@ const deserializeAws_queryDescribeCacheEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3164,8 +3192,7 @@ const deserializeAws_queryDescribeCacheParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupNotFoundFault": case "com.amazonaws.elasticache#CacheParameterGroupNotFoundFault": @@ -3178,10 +3205,12 @@ const deserializeAws_queryDescribeCacheParameterGroupsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3213,8 +3242,7 @@ const deserializeAws_queryDescribeCacheParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupNotFoundFault": case "com.amazonaws.elasticache#CacheParameterGroupNotFoundFault": @@ -3227,10 +3255,12 @@ const deserializeAws_queryDescribeCacheParametersCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3262,8 +3292,7 @@ const deserializeAws_queryDescribeCacheSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSecurityGroupNotFoundFault": case "com.amazonaws.elasticache#CacheSecurityGroupNotFoundFault": @@ -3276,10 +3305,12 @@ const deserializeAws_queryDescribeCacheSecurityGroupsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3311,18 +3342,19 @@ const deserializeAws_queryDescribeCacheSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSubnetGroupNotFoundFault": case "com.amazonaws.elasticache#CacheSubnetGroupNotFoundFault": throw await deserializeAws_queryCacheSubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3357,8 +3389,7 @@ const deserializeAws_queryDescribeEngineDefaultParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3368,10 +3399,12 @@ const deserializeAws_queryDescribeEngineDefaultParametersCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3403,8 +3436,7 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3414,10 +3446,12 @@ const deserializeAws_queryDescribeEventsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3452,8 +3486,7 @@ const deserializeAws_queryDescribeGlobalReplicationGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -3466,10 +3499,12 @@ const deserializeAws_queryDescribeGlobalReplicationGroupsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3501,8 +3536,7 @@ const deserializeAws_queryDescribeReplicationGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3515,10 +3549,12 @@ const deserializeAws_queryDescribeReplicationGroupsCommandError = async ( throw await deserializeAws_queryReplicationGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3550,8 +3586,7 @@ const deserializeAws_queryDescribeReservedCacheNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3564,10 +3599,12 @@ const deserializeAws_queryDescribeReservedCacheNodesCommandError = async ( throw await deserializeAws_queryReservedCacheNodeNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3602,8 +3639,7 @@ const deserializeAws_queryDescribeReservedCacheNodesOfferingsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3616,10 +3652,12 @@ const deserializeAws_queryDescribeReservedCacheNodesOfferingsCommandError = asyn throw await deserializeAws_queryReservedCacheNodesOfferingNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3651,8 +3689,7 @@ const deserializeAws_queryDescribeServiceUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3665,10 +3702,12 @@ const deserializeAws_queryDescribeServiceUpdatesCommandError = async ( throw await deserializeAws_queryServiceUpdateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3700,8 +3739,7 @@ const deserializeAws_queryDescribeSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -3717,10 +3755,12 @@ const deserializeAws_queryDescribeSnapshotsCommandError = async ( throw await deserializeAws_querySnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3752,8 +3792,7 @@ const deserializeAws_queryDescribeUpdateActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3763,10 +3802,12 @@ const deserializeAws_queryDescribeUpdateActionsCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3798,8 +3839,7 @@ const deserializeAws_queryDescribeUserGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3812,10 +3852,12 @@ const deserializeAws_queryDescribeUserGroupsCommandError = async ( throw await deserializeAws_queryUserGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3847,8 +3889,7 @@ const deserializeAws_queryDescribeUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -3861,10 +3902,12 @@ const deserializeAws_queryDescribeUsersCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3899,8 +3942,7 @@ const deserializeAws_queryDisassociateGlobalReplicationGroupCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -3916,10 +3958,12 @@ const deserializeAws_queryDisassociateGlobalReplicationGroupCommandError = async throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3954,8 +3998,7 @@ const deserializeAws_queryFailoverGlobalReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -3971,10 +4014,12 @@ const deserializeAws_queryFailoverGlobalReplicationGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4009,8 +4054,7 @@ const deserializeAws_queryIncreaseNodeGroupsInGlobalReplicationGroupCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -4023,10 +4067,12 @@ const deserializeAws_queryIncreaseNodeGroupsInGlobalReplicationGroupCommandError throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4058,8 +4104,7 @@ const deserializeAws_queryIncreaseReplicaCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterQuotaForCustomerExceededFault": case "com.amazonaws.elasticache#ClusterQuotaForCustomerExceededFault": @@ -4099,10 +4144,12 @@ const deserializeAws_queryIncreaseReplicaCountCommandError = async ( throw await deserializeAws_queryReplicationGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4137,8 +4184,7 @@ const deserializeAws_queryListAllowedNodeTypeModificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4154,10 +4200,12 @@ const deserializeAws_queryListAllowedNodeTypeModificationsCommandError = async ( throw await deserializeAws_queryReplicationGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4189,8 +4237,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4227,10 +4274,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4262,8 +4311,7 @@ const deserializeAws_queryModifyCacheClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4300,10 +4348,12 @@ const deserializeAws_queryModifyCacheClusterCommandError = async ( throw await deserializeAws_queryNodeQuotaForCustomerExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4335,8 +4385,7 @@ const deserializeAws_queryModifyCacheParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupNotFoundFault": case "com.amazonaws.elasticache#CacheParameterGroupNotFoundFault": @@ -4355,10 +4404,12 @@ const deserializeAws_queryModifyCacheParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4390,8 +4441,7 @@ const deserializeAws_queryModifyCacheSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheSubnetGroupNotFoundFault": case "com.amazonaws.elasticache#CacheSubnetGroupNotFoundFault": @@ -4410,10 +4460,12 @@ const deserializeAws_queryModifyCacheSubnetGroupCommandError = async ( throw await deserializeAws_querySubnetNotAllowedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4445,8 +4497,7 @@ const deserializeAws_queryModifyGlobalReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -4459,10 +4510,12 @@ const deserializeAws_queryModifyGlobalReplicationGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4494,8 +4547,7 @@ const deserializeAws_queryModifyReplicationGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4547,10 +4599,12 @@ const deserializeAws_queryModifyReplicationGroupCommandError = async ( throw await deserializeAws_queryUserGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4585,8 +4639,7 @@ const deserializeAws_queryModifyReplicationGroupShardConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCacheClusterCapacityFault": case "com.amazonaws.elasticache#InsufficientCacheClusterCapacityFault": @@ -4620,10 +4673,12 @@ const deserializeAws_queryModifyReplicationGroupShardConfigurationCommandError = throw await deserializeAws_queryReplicationGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4655,8 +4710,7 @@ const deserializeAws_queryModifyUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -4675,10 +4729,12 @@ const deserializeAws_queryModifyUserCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4710,8 +4766,7 @@ const deserializeAws_queryModifyUserGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DefaultUserRequired": case "com.amazonaws.elasticache#DefaultUserRequired": @@ -4739,10 +4794,12 @@ const deserializeAws_queryModifyUserGroupCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4777,8 +4834,7 @@ const deserializeAws_queryPurchaseReservedCacheNodesOfferingCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.elasticache#InvalidParameterCombinationException": @@ -4800,10 +4856,12 @@ const deserializeAws_queryPurchaseReservedCacheNodesOfferingCommandError = async throw await deserializeAws_queryTagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4838,8 +4896,7 @@ const deserializeAws_queryRebalanceSlotsInGlobalReplicationGroupCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalReplicationGroupNotFoundFault": case "com.amazonaws.elasticache#GlobalReplicationGroupNotFoundFault": @@ -4852,10 +4909,12 @@ const deserializeAws_queryRebalanceSlotsInGlobalReplicationGroupCommandError = a throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4887,8 +4946,7 @@ const deserializeAws_queryRebootCacheClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4898,10 +4956,12 @@ const deserializeAws_queryRebootCacheClusterCommandError = async ( throw await deserializeAws_queryInvalidCacheClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4933,8 +4993,7 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheClusterNotFoundFault": case "com.amazonaws.elasticache#CacheClusterNotFoundFault": @@ -4974,10 +5033,12 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( throw await deserializeAws_queryUserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5009,8 +5070,7 @@ const deserializeAws_queryResetCacheParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CacheParameterGroupNotFoundFault": case "com.amazonaws.elasticache#CacheParameterGroupNotFoundFault": @@ -5029,10 +5089,12 @@ const deserializeAws_queryResetCacheParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5067,8 +5129,7 @@ const deserializeAws_queryRevokeCacheSecurityGroupIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.elasticache#AuthorizationNotFoundFault": @@ -5087,10 +5148,12 @@ const deserializeAws_queryRevokeCacheSecurityGroupIngressCommandError = async ( throw await deserializeAws_queryInvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5122,8 +5185,7 @@ const deserializeAws_queryStartMigrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.elasticache#InvalidParameterValueException": @@ -5139,10 +5201,12 @@ const deserializeAws_queryStartMigrationCommandError = async ( throw await deserializeAws_queryReplicationGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5174,8 +5238,7 @@ const deserializeAws_queryTestFailoverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "APICallRateForCustomerExceededFault": case "com.amazonaws.elasticache#APICallRateForCustomerExceededFault": @@ -5206,10 +5269,12 @@ const deserializeAws_queryTestFailoverCommandError = async ( throw await deserializeAws_queryTestFailoverNotAvailableFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -12790,12 +12855,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-elasticsearch-service/src/protocols/Aws_restJson1.ts b/clients/client-elasticsearch-service/src/protocols/Aws_restJson1.ts index cfbd71376c2d9..625a8a27bc8ff 100644 --- a/clients/client-elasticsearch-service/src/protocols/Aws_restJson1.ts +++ b/clients/client-elasticsearch-service/src/protocols/Aws_restJson1.ts @@ -1618,8 +1618,7 @@ const deserializeAws_restJson1AcceptInboundCrossClusterSearchConnectionCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -1632,10 +1631,12 @@ const deserializeAws_restJson1AcceptInboundCrossClusterSearchConnectionCommandEr throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1664,8 +1665,7 @@ const deserializeAws_restJson1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -1681,10 +1681,12 @@ const deserializeAws_restJson1AddTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1717,8 +1719,7 @@ const deserializeAws_restJson1AssociatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -1740,10 +1741,12 @@ const deserializeAws_restJson1AssociatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1779,8 +1782,7 @@ const deserializeAws_restJson1CancelElasticsearchServiceSoftwareUpdateCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -1796,10 +1798,12 @@ const deserializeAws_restJson1CancelElasticsearchServiceSoftwareUpdateCommandErr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1832,8 +1836,7 @@ const deserializeAws_restJson1CreateElasticsearchDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -1858,10 +1861,12 @@ const deserializeAws_restJson1CreateElasticsearchDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1918,7 @@ const deserializeAws_restJson1CreateOutboundCrossClusterSearchConnectionCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -1930,10 +1934,12 @@ const deserializeAws_restJson1CreateOutboundCrossClusterSearchConnectionCommandE throw await deserializeAws_restJson1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1966,8 +1972,7 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -1992,10 +1997,12 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2028,8 +2035,7 @@ const deserializeAws_restJson1DeleteElasticsearchDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2045,10 +2051,12 @@ const deserializeAws_restJson1DeleteElasticsearchDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,8 +2085,7 @@ const deserializeAws_restJson1DeleteElasticsearchServiceRoleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2091,10 +2098,12 @@ const deserializeAws_restJson1DeleteElasticsearchServiceRoleCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2130,8 +2139,7 @@ const deserializeAws_restJson1DeleteInboundCrossClusterSearchConnectionCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2141,10 +2149,12 @@ const deserializeAws_restJson1DeleteInboundCrossClusterSearchConnectionCommandEr throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2180,8 +2190,7 @@ const deserializeAws_restJson1DeleteOutboundCrossClusterSearchConnectionCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2191,10 +2200,12 @@ const deserializeAws_restJson1DeleteOutboundCrossClusterSearchConnectionCommandE throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2227,8 +2238,7 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -2250,10 +2260,12 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2290,8 +2302,7 @@ const deserializeAws_restJson1DescribeDomainAutoTunesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2307,10 +2318,12 @@ const deserializeAws_restJson1DescribeDomainAutoTunesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2346,8 +2359,7 @@ const deserializeAws_restJson1DescribeDomainChangeProgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2363,10 +2375,12 @@ const deserializeAws_restJson1DescribeDomainChangeProgressCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2399,8 +2413,7 @@ const deserializeAws_restJson1DescribeElasticsearchDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2416,10 +2429,12 @@ const deserializeAws_restJson1DescribeElasticsearchDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2452,8 +2467,7 @@ const deserializeAws_restJson1DescribeElasticsearchDomainConfigCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2469,10 +2483,12 @@ const deserializeAws_restJson1DescribeElasticsearchDomainConfigCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2505,8 +2521,7 @@ const deserializeAws_restJson1DescribeElasticsearchDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2519,10 +2534,12 @@ const deserializeAws_restJson1DescribeElasticsearchDomainsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2555,8 +2572,7 @@ const deserializeAws_restJson1DescribeElasticsearchInstanceTypeLimitsCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2578,10 +2594,12 @@ const deserializeAws_restJson1DescribeElasticsearchInstanceTypeLimitsCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2621,8 +2639,7 @@ const deserializeAws_restJson1DescribeInboundCrossClusterSearchConnectionsComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2632,10 +2649,12 @@ const deserializeAws_restJson1DescribeInboundCrossClusterSearchConnectionsComman throw await deserializeAws_restJson1InvalidPaginationTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2675,8 +2694,7 @@ const deserializeAws_restJson1DescribeOutboundCrossClusterSearchConnectionsComma body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2686,10 +2704,12 @@ const deserializeAws_restJson1DescribeOutboundCrossClusterSearchConnectionsComma throw await deserializeAws_restJson1InvalidPaginationTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2726,8 +2746,7 @@ const deserializeAws_restJson1DescribePackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -2746,10 +2765,12 @@ const deserializeAws_restJson1DescribePackagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2792,8 +2813,7 @@ const deserializeAws_restJson1DescribeReservedElasticsearchInstanceOfferingsComm body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2809,10 +2829,12 @@ const deserializeAws_restJson1DescribeReservedElasticsearchInstanceOfferingsComm throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2852,8 +2874,7 @@ const deserializeAws_restJson1DescribeReservedElasticsearchInstancesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -2869,10 +2890,12 @@ const deserializeAws_restJson1DescribeReservedElasticsearchInstancesCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2905,8 +2928,7 @@ const deserializeAws_restJson1DissociatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -2928,10 +2950,12 @@ const deserializeAws_restJson1DissociatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2967,8 +2991,7 @@ const deserializeAws_restJson1GetCompatibleElasticsearchVersionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -2987,10 +3010,12 @@ const deserializeAws_restJson1GetCompatibleElasticsearchVersionsCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3034,8 +3059,7 @@ const deserializeAws_restJson1GetPackageVersionHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -3054,10 +3078,12 @@ const deserializeAws_restJson1GetPackageVersionHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3094,8 +3120,7 @@ const deserializeAws_restJson1GetUpgradeHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3114,10 +3139,12 @@ const deserializeAws_restJson1GetUpgradeHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3158,8 +3185,7 @@ const deserializeAws_restJson1GetUpgradeStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3178,10 +3204,12 @@ const deserializeAws_restJson1GetUpgradeStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3214,8 +3242,7 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3225,10 +3252,12 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3268,8 +3297,7 @@ const deserializeAws_restJson1ListDomainsForPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -3288,10 +3316,12 @@ const deserializeAws_restJson1ListDomainsForPackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3331,8 +3361,7 @@ const deserializeAws_restJson1ListElasticsearchInstanceTypesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3348,10 +3377,12 @@ const deserializeAws_restJson1ListElasticsearchInstanceTypesCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3391,8 +3422,7 @@ const deserializeAws_restJson1ListElasticsearchVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3408,10 +3438,12 @@ const deserializeAws_restJson1ListElasticsearchVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3451,8 +3483,7 @@ const deserializeAws_restJson1ListPackagesForDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -3471,10 +3502,12 @@ const deserializeAws_restJson1ListPackagesForDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3507,8 +3540,7 @@ const deserializeAws_restJson1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3524,10 +3556,12 @@ const deserializeAws_restJson1ListTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3564,8 +3598,7 @@ const deserializeAws_restJson1PurchaseReservedElasticsearchInstanceOfferingComma body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -3587,10 +3620,12 @@ const deserializeAws_restJson1PurchaseReservedElasticsearchInstanceOfferingComma throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3626,8 +3661,7 @@ const deserializeAws_restJson1RejectInboundCrossClusterSearchConnectionCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.elasticsearchservice#DisabledOperationException": @@ -3637,10 +3671,12 @@ const deserializeAws_restJson1RejectInboundCrossClusterSearchConnectionCommandEr throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3669,8 +3705,7 @@ const deserializeAws_restJson1RemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3683,10 +3718,12 @@ const deserializeAws_restJson1RemoveTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3722,8 +3759,7 @@ const deserializeAws_restJson1StartElasticsearchServiceSoftwareUpdateCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3739,10 +3775,12 @@ const deserializeAws_restJson1StartElasticsearchServiceSoftwareUpdateCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3779,8 +3817,7 @@ const deserializeAws_restJson1UpdateElasticsearchDomainConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3802,10 +3839,12 @@ const deserializeAws_restJson1UpdateElasticsearchDomainConfigCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3838,8 +3877,7 @@ const deserializeAws_restJson1UpdatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.elasticsearchservice#AccessDeniedException": @@ -3861,10 +3899,12 @@ const deserializeAws_restJson1UpdatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3909,8 +3949,7 @@ const deserializeAws_restJson1UpgradeElasticsearchDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.elasticsearchservice#BaseException": @@ -3932,10 +3971,12 @@ const deserializeAws_restJson1UpgradeElasticsearchDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5903,7 +5944,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5929,6 +5970,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-emr-containers/src/protocols/Aws_restJson1.ts b/clients/client-emr-containers/src/protocols/Aws_restJson1.ts index 61c6da7d1f593..677a347874551 100644 --- a/clients/client-emr-containers/src/protocols/Aws_restJson1.ts +++ b/clients/client-emr-containers/src/protocols/Aws_restJson1.ts @@ -658,8 +658,7 @@ const deserializeAws_restJson1CancelJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -669,10 +668,12 @@ const deserializeAws_restJson1CancelJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -717,8 +718,7 @@ const deserializeAws_restJson1CreateManagedEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -731,10 +731,12 @@ const deserializeAws_restJson1CreateManagedEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -775,8 +777,7 @@ const deserializeAws_restJson1CreateVirtualClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -789,10 +790,12 @@ const deserializeAws_restJson1CreateVirtualClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -829,8 +832,7 @@ const deserializeAws_restJson1DeleteManagedEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -840,10 +842,12 @@ const deserializeAws_restJson1DeleteManagedEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -876,8 +880,7 @@ const deserializeAws_restJson1DeleteVirtualClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -887,10 +890,12 @@ const deserializeAws_restJson1DeleteVirtualClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -923,8 +928,7 @@ const deserializeAws_restJson1DescribeJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -937,10 +941,12 @@ const deserializeAws_restJson1DescribeJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -973,8 +979,7 @@ const deserializeAws_restJson1DescribeManagedEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -987,10 +992,12 @@ const deserializeAws_restJson1DescribeManagedEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1023,8 +1030,7 @@ const deserializeAws_restJson1DescribeVirtualClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1037,10 +1043,12 @@ const deserializeAws_restJson1DescribeVirtualClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1077,8 +1085,7 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1088,10 +1095,12 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1128,8 +1137,7 @@ const deserializeAws_restJson1ListManagedEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1139,10 +1147,12 @@ const deserializeAws_restJson1ListManagedEndpointsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1175,8 +1185,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1189,10 +1198,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1229,8 +1240,7 @@ const deserializeAws_restJson1ListVirtualClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1240,10 +1250,12 @@ const deserializeAws_restJson1ListVirtualClustersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1288,8 +1300,7 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1302,10 +1313,12 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1334,8 +1347,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1348,10 +1360,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1380,8 +1394,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrcontainers#InternalServerException": @@ -1394,10 +1407,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1962,7 +1977,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1988,6 +2003,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-emr-serverless/src/protocols/Aws_restJson1.ts b/clients/client-emr-serverless/src/protocols/Aws_restJson1.ts index b2e7edfaed494..d01b024affd61 100644 --- a/clients/client-emr-serverless/src/protocols/Aws_restJson1.ts +++ b/clients/client-emr-serverless/src/protocols/Aws_restJson1.ts @@ -602,8 +602,7 @@ const deserializeAws_restJson1CancelJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -616,10 +615,12 @@ const deserializeAws_restJson1CancelJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -660,8 +661,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.emrserverless#ConflictException": @@ -674,10 +674,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -706,8 +708,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -720,10 +721,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -756,8 +759,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -770,10 +772,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -806,8 +810,7 @@ const deserializeAws_restJson1GetJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -820,10 +823,12 @@ const deserializeAws_restJson1GetJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -860,8 +865,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -871,10 +875,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +917,7 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -922,10 +927,12 @@ const deserializeAws_restJson1ListJobRunsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -958,8 +965,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -972,10 +978,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1004,8 +1012,7 @@ const deserializeAws_restJson1StartApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -1021,10 +1028,12 @@ const deserializeAws_restJson1StartApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1065,8 +1074,7 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.emrserverless#ConflictException": @@ -1082,10 +1090,12 @@ const deserializeAws_restJson1StartJobRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1114,8 +1124,7 @@ const deserializeAws_restJson1StopApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -1128,10 +1137,12 @@ const deserializeAws_restJson1StopApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1171,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -1174,10 +1184,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1218,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -1220,10 +1231,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1256,8 +1269,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emrserverless#InternalServerException": @@ -1270,10 +1282,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2046,7 +2060,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2072,6 +2086,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-emr/src/protocols/Aws_json1_1.ts b/clients/client-emr/src/protocols/Aws_json1_1.ts index a29775822a05d..2f51b6c6017ec 100644 --- a/clients/client-emr/src/protocols/Aws_json1_1.ts +++ b/clients/client-emr/src/protocols/Aws_json1_1.ts @@ -1057,8 +1057,7 @@ const deserializeAws_json1_1AddInstanceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1068,10 +1067,12 @@ const deserializeAws_json1_1AddInstanceFleetCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1103,18 +1104,19 @@ const deserializeAws_json1_1AddInstanceGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1146,18 +1148,19 @@ const deserializeAws_json1_1AddJobFlowStepsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1189,8 +1192,7 @@ const deserializeAws_json1_1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1200,10 +1202,12 @@ const deserializeAws_json1_1AddTagsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1235,8 +1239,7 @@ const deserializeAws_json1_1CancelStepsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -1246,10 +1249,12 @@ const deserializeAws_json1_1CancelStepsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1281,8 +1286,7 @@ const deserializeAws_json1_1CreateSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1292,10 +1296,12 @@ const deserializeAws_json1_1CreateSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1327,8 +1333,7 @@ const deserializeAws_json1_1CreateStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1338,10 +1343,12 @@ const deserializeAws_json1_1CreateStudioCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1370,8 +1377,7 @@ const deserializeAws_json1_1CreateStudioSessionMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -1381,10 +1387,12 @@ const deserializeAws_json1_1CreateStudioSessionMappingCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1416,8 +1424,7 @@ const deserializeAws_json1_1DeleteSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1427,10 +1434,12 @@ const deserializeAws_json1_1DeleteSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1459,8 +1468,7 @@ const deserializeAws_json1_1DeleteStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1470,10 +1478,12 @@ const deserializeAws_json1_1DeleteStudioCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1502,8 +1512,7 @@ const deserializeAws_json1_1DeleteStudioSessionMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -1513,10 +1522,12 @@ const deserializeAws_json1_1DeleteStudioSessionMappingCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1548,8 +1559,7 @@ const deserializeAws_json1_1DescribeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1559,10 +1569,12 @@ const deserializeAws_json1_1DescribeClusterCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1594,18 +1606,19 @@ const deserializeAws_json1_1DescribeJobFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1637,8 +1650,7 @@ const deserializeAws_json1_1DescribeNotebookExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -1648,10 +1660,12 @@ const deserializeAws_json1_1DescribeNotebookExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1683,8 +1697,7 @@ const deserializeAws_json1_1DescribeReleaseLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1694,10 +1707,12 @@ const deserializeAws_json1_1DescribeReleaseLabelCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1729,8 +1744,7 @@ const deserializeAws_json1_1DescribeSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1740,10 +1754,12 @@ const deserializeAws_json1_1DescribeSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1775,8 +1791,7 @@ const deserializeAws_json1_1DescribeStepCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1786,10 +1801,12 @@ const deserializeAws_json1_1DescribeStepCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1821,8 +1838,7 @@ const deserializeAws_json1_1DescribeStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1832,10 +1848,12 @@ const deserializeAws_json1_1DescribeStudioCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1867,15 +1885,16 @@ const deserializeAws_json1_1GetAutoTerminationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1907,8 +1926,7 @@ const deserializeAws_json1_1GetBlockPublicAccessConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -1918,10 +1936,12 @@ const deserializeAws_json1_1GetBlockPublicAccessConfigurationCommandError = asyn throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,15 +1973,16 @@ const deserializeAws_json1_1GetManagedScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1993,8 +2014,7 @@ const deserializeAws_json1_1GetStudioSessionMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -2004,10 +2024,12 @@ const deserializeAws_json1_1GetStudioSessionMappingCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2039,8 +2061,7 @@ const deserializeAws_json1_1ListBootstrapActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2050,10 +2071,12 @@ const deserializeAws_json1_1ListBootstrapActionsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2085,8 +2108,7 @@ const deserializeAws_json1_1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2096,10 +2118,12 @@ const deserializeAws_json1_1ListClustersCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2131,8 +2155,7 @@ const deserializeAws_json1_1ListInstanceFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2142,10 +2165,12 @@ const deserializeAws_json1_1ListInstanceFleetsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2177,8 +2202,7 @@ const deserializeAws_json1_1ListInstanceGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2188,10 +2212,12 @@ const deserializeAws_json1_1ListInstanceGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2223,8 +2249,7 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2234,10 +2259,12 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2269,8 +2296,7 @@ const deserializeAws_json1_1ListNotebookExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -2280,10 +2306,12 @@ const deserializeAws_json1_1ListNotebookExecutionsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2315,8 +2343,7 @@ const deserializeAws_json1_1ListReleaseLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2326,10 +2353,12 @@ const deserializeAws_json1_1ListReleaseLabelsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2361,8 +2390,7 @@ const deserializeAws_json1_1ListSecurityConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2372,10 +2400,12 @@ const deserializeAws_json1_1ListSecurityConfigurationsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2407,8 +2437,7 @@ const deserializeAws_json1_1ListStepsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2418,10 +2447,12 @@ const deserializeAws_json1_1ListStepsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2453,8 +2484,7 @@ const deserializeAws_json1_1ListStudiosCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2464,10 +2494,12 @@ const deserializeAws_json1_1ListStudiosCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2499,8 +2531,7 @@ const deserializeAws_json1_1ListStudioSessionMappingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -2510,10 +2541,12 @@ const deserializeAws_json1_1ListStudioSessionMappingsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2545,8 +2578,7 @@ const deserializeAws_json1_1ModifyClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -2556,10 +2588,12 @@ const deserializeAws_json1_1ModifyClusterCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2588,8 +2622,7 @@ const deserializeAws_json1_1ModifyInstanceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2599,10 +2632,12 @@ const deserializeAws_json1_1ModifyInstanceFleetCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2631,18 +2666,19 @@ const deserializeAws_json1_1ModifyInstanceGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2674,15 +2710,16 @@ const deserializeAws_json1_1PutAutoScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2714,15 +2751,16 @@ const deserializeAws_json1_1PutAutoTerminationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2754,8 +2792,7 @@ const deserializeAws_json1_1PutBlockPublicAccessConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2765,10 +2802,12 @@ const deserializeAws_json1_1PutBlockPublicAccessConfigurationCommandError = asyn throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2800,15 +2839,16 @@ const deserializeAws_json1_1PutManagedScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2840,15 +2880,16 @@ const deserializeAws_json1_1RemoveAutoScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2880,15 +2921,16 @@ const deserializeAws_json1_1RemoveAutoTerminationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2920,15 +2962,16 @@ const deserializeAws_json1_1RemoveManagedScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2960,8 +3003,7 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -2971,10 +3013,12 @@ const deserializeAws_json1_1RemoveTagsCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3006,18 +3050,19 @@ const deserializeAws_json1_1RunJobFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3046,18 +3091,19 @@ const deserializeAws_json1_1SetTerminationProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3086,18 +3132,19 @@ const deserializeAws_json1_1SetVisibleToAllUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3129,8 +3176,7 @@ const deserializeAws_json1_1StartNotebookExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -3140,10 +3186,12 @@ const deserializeAws_json1_1StartNotebookExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3172,8 +3220,7 @@ const deserializeAws_json1_1StopNotebookExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -3183,10 +3230,12 @@ const deserializeAws_json1_1StopNotebookExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3215,18 +3264,19 @@ const deserializeAws_json1_1TerminateJobFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3255,8 +3305,7 @@ const deserializeAws_json1_1UpdateStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.emr#InternalServerException": @@ -3266,10 +3315,12 @@ const deserializeAws_json1_1UpdateStudioCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3298,8 +3349,7 @@ const deserializeAws_json1_1UpdateStudioSessionMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.emr#InternalServerError": @@ -3309,10 +3359,12 @@ const deserializeAws_json1_1UpdateStudioSessionMappingCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7120,7 +7172,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7146,6 +7198,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-eventbridge/src/protocols/Aws_json1_1.ts b/clients/client-eventbridge/src/protocols/Aws_json1_1.ts index f400c139fd461..e1c45b6a3178d 100644 --- a/clients/client-eventbridge/src/protocols/Aws_json1_1.ts +++ b/clients/client-eventbridge/src/protocols/Aws_json1_1.ts @@ -1055,8 +1055,7 @@ const deserializeAws_json1_1ActivateEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1075,10 +1074,12 @@ const deserializeAws_json1_1ActivateEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1110,8 +1111,7 @@ const deserializeAws_json1_1CancelReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1127,10 +1127,12 @@ const deserializeAws_json1_1CancelReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1162,8 +1164,7 @@ const deserializeAws_json1_1CreateApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -1179,10 +1180,12 @@ const deserializeAws_json1_1CreateApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1214,8 +1217,7 @@ const deserializeAws_json1_1CreateArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1237,10 +1239,12 @@ const deserializeAws_json1_1CreateArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1272,8 +1276,7 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -1286,10 +1289,12 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1321,8 +1326,7 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -1335,10 +1339,12 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1370,8 +1376,7 @@ const deserializeAws_json1_1CreateEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1396,10 +1401,12 @@ const deserializeAws_json1_1CreateEventBusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1431,8 +1438,7 @@ const deserializeAws_json1_1CreatePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1451,10 +1457,12 @@ const deserializeAws_json1_1CreatePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1483,8 +1491,7 @@ const deserializeAws_json1_1DeactivateEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1503,10 +1510,12 @@ const deserializeAws_json1_1DeactivateEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1538,8 +1547,7 @@ const deserializeAws_json1_1DeauthorizeConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1552,10 +1560,12 @@ const deserializeAws_json1_1DeauthorizeConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1587,8 +1597,7 @@ const deserializeAws_json1_1DeleteApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1601,10 +1610,12 @@ const deserializeAws_json1_1DeleteApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1636,8 +1647,7 @@ const deserializeAws_json1_1DeleteArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1650,10 +1660,12 @@ const deserializeAws_json1_1DeleteArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1685,8 +1697,7 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1699,10 +1710,12 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1734,8 +1747,7 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1748,10 +1760,12 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1780,8 +1794,7 @@ const deserializeAws_json1_1DeleteEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1791,10 +1804,12 @@ const deserializeAws_json1_1DeleteEventBusCommandError = async ( throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1823,8 +1838,7 @@ const deserializeAws_json1_1DeletePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1837,10 +1851,12 @@ const deserializeAws_json1_1DeletePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1869,8 +1885,7 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -1886,10 +1901,12 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1921,8 +1938,7 @@ const deserializeAws_json1_1DescribeApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -1932,10 +1948,12 @@ const deserializeAws_json1_1DescribeApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1967,8 +1985,7 @@ const deserializeAws_json1_1DescribeArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -1981,10 +1998,12 @@ const deserializeAws_json1_1DescribeArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2016,8 +2035,7 @@ const deserializeAws_json1_1DescribeConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2027,10 +2045,12 @@ const deserializeAws_json1_1DescribeConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2062,8 +2082,7 @@ const deserializeAws_json1_1DescribeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2073,10 +2092,12 @@ const deserializeAws_json1_1DescribeEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2108,8 +2129,7 @@ const deserializeAws_json1_1DescribeEventBusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2119,10 +2139,12 @@ const deserializeAws_json1_1DescribeEventBusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2154,8 +2176,7 @@ const deserializeAws_json1_1DescribeEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2168,10 +2189,12 @@ const deserializeAws_json1_1DescribeEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2203,8 +2226,7 @@ const deserializeAws_json1_1DescribePartnerEventSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2217,10 +2239,12 @@ const deserializeAws_json1_1DescribePartnerEventSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2252,8 +2276,7 @@ const deserializeAws_json1_1DescribeReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2263,10 +2286,12 @@ const deserializeAws_json1_1DescribeReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2298,8 +2323,7 @@ const deserializeAws_json1_1DescribeRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2309,10 +2333,12 @@ const deserializeAws_json1_1DescribeRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2341,8 +2367,7 @@ const deserializeAws_json1_1DisableRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -2358,10 +2383,12 @@ const deserializeAws_json1_1DisableRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2390,8 +2417,7 @@ const deserializeAws_json1_1EnableRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -2407,10 +2433,12 @@ const deserializeAws_json1_1EnableRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2442,18 +2470,19 @@ const deserializeAws_json1_1ListApiDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2485,8 +2514,7 @@ const deserializeAws_json1_1ListArchivesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2496,10 +2524,12 @@ const deserializeAws_json1_1ListArchivesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2531,18 +2561,19 @@ const deserializeAws_json1_1ListConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2574,18 +2605,19 @@ const deserializeAws_json1_1ListEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2617,18 +2649,19 @@ const deserializeAws_json1_1ListEventBusesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2660,8 +2693,7 @@ const deserializeAws_json1_1ListEventSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2671,10 +2703,12 @@ const deserializeAws_json1_1ListEventSourcesCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2706,8 +2740,7 @@ const deserializeAws_json1_1ListPartnerEventSourceAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2720,10 +2753,12 @@ const deserializeAws_json1_1ListPartnerEventSourceAccountsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2755,8 +2790,7 @@ const deserializeAws_json1_1ListPartnerEventSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2766,10 +2800,12 @@ const deserializeAws_json1_1ListPartnerEventSourcesCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2801,18 +2837,19 @@ const deserializeAws_json1_1ListReplaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2844,8 +2881,7 @@ const deserializeAws_json1_1ListRuleNamesByTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2855,10 +2891,12 @@ const deserializeAws_json1_1ListRuleNamesByTargetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2890,8 +2928,7 @@ const deserializeAws_json1_1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2901,10 +2938,12 @@ const deserializeAws_json1_1ListRulesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2936,8 +2975,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2947,10 +2985,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2982,8 +3022,7 @@ const deserializeAws_json1_1ListTargetsByRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -2993,10 +3032,12 @@ const deserializeAws_json1_1ListTargetsByRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3028,18 +3069,19 @@ const deserializeAws_json1_1PutEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3071,8 +3113,7 @@ const deserializeAws_json1_1PutPartnerEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -3082,10 +3123,12 @@ const deserializeAws_json1_1PutPartnerEventsCommandError = async ( throw await deserializeAws_json1_1OperationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3114,8 +3157,7 @@ const deserializeAws_json1_1PutPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3134,10 +3176,12 @@ const deserializeAws_json1_1PutPermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3169,8 +3213,7 @@ const deserializeAws_json1_1PutRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3192,10 +3235,12 @@ const deserializeAws_json1_1PutRuleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3227,8 +3272,7 @@ const deserializeAws_json1_1PutTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3247,10 +3291,12 @@ const deserializeAws_json1_1PutTargetsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3279,8 +3325,7 @@ const deserializeAws_json1_1RemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3296,10 +3341,12 @@ const deserializeAws_json1_1RemovePermissionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3331,8 +3378,7 @@ const deserializeAws_json1_1RemoveTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3348,10 +3394,12 @@ const deserializeAws_json1_1RemoveTargetsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3383,8 +3431,7 @@ const deserializeAws_json1_1StartReplayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -3403,10 +3450,12 @@ const deserializeAws_json1_1StartReplayCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3438,8 +3487,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3455,10 +3503,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3490,8 +3540,7 @@ const deserializeAws_json1_1TestEventPatternCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.eventbridge#InternalException": @@ -3501,10 +3550,12 @@ const deserializeAws_json1_1TestEventPatternCommandError = async ( throw await deserializeAws_json1_1InvalidEventPatternExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3536,8 +3587,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3553,10 +3603,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3588,8 +3640,7 @@ const deserializeAws_json1_1UpdateApiDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3605,10 +3656,12 @@ const deserializeAws_json1_1UpdateApiDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3640,8 +3693,7 @@ const deserializeAws_json1_1UpdateArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3660,10 +3712,12 @@ const deserializeAws_json1_1UpdateArchiveCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3695,8 +3749,7 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3712,10 +3765,12 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3747,8 +3802,7 @@ const deserializeAws_json1_1UpdateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.eventbridge#ConcurrentModificationException": @@ -3761,10 +3815,12 @@ const deserializeAws_json1_1UpdateEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7220,7 +7276,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7246,6 +7302,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-evidently/src/protocols/Aws_restJson1.ts b/clients/client-evidently/src/protocols/Aws_restJson1.ts index 9e04e838950a2..a464cc2056edd 100644 --- a/clients/client-evidently/src/protocols/Aws_restJson1.ts +++ b/clients/client-evidently/src/protocols/Aws_restJson1.ts @@ -1459,8 +1459,7 @@ const deserializeAws_restJson1BatchEvaluateFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1476,10 +1475,12 @@ const deserializeAws_restJson1BatchEvaluateFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1512,8 +1513,7 @@ const deserializeAws_restJson1CreateExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1532,10 +1532,12 @@ const deserializeAws_restJson1CreateExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1568,8 +1570,7 @@ const deserializeAws_restJson1CreateFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1588,10 +1589,12 @@ const deserializeAws_restJson1CreateFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1624,8 +1627,7 @@ const deserializeAws_restJson1CreateLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1644,10 +1646,12 @@ const deserializeAws_restJson1CreateLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1680,8 +1684,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1697,10 +1700,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1729,8 +1734,7 @@ const deserializeAws_restJson1DeleteExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1752,10 +1756,12 @@ const deserializeAws_restJson1DeleteExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1784,8 +1790,7 @@ const deserializeAws_restJson1DeleteFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1804,10 +1809,12 @@ const deserializeAws_restJson1DeleteFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1836,8 +1843,7 @@ const deserializeAws_restJson1DeleteLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1856,10 +1862,12 @@ const deserializeAws_restJson1DeleteLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1888,8 +1896,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1908,10 +1915,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1956,8 +1965,7 @@ const deserializeAws_restJson1EvaluateFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -1973,10 +1981,12 @@ const deserializeAws_restJson1EvaluateFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2009,8 +2019,7 @@ const deserializeAws_restJson1GetExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2026,10 +2035,12 @@ const deserializeAws_restJson1GetExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2074,8 +2085,7 @@ const deserializeAws_restJson1GetExperimentResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2094,10 +2104,12 @@ const deserializeAws_restJson1GetExperimentResultsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2130,8 +2142,7 @@ const deserializeAws_restJson1GetFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2147,10 +2158,12 @@ const deserializeAws_restJson1GetFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2183,8 +2196,7 @@ const deserializeAws_restJson1GetLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2200,10 +2212,12 @@ const deserializeAws_restJson1GetLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2236,8 +2250,7 @@ const deserializeAws_restJson1GetProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2253,10 +2266,12 @@ const deserializeAws_restJson1GetProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2293,8 +2308,7 @@ const deserializeAws_restJson1ListExperimentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2307,10 +2321,12 @@ const deserializeAws_restJson1ListExperimentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2347,8 +2363,7 @@ const deserializeAws_restJson1ListFeaturesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2364,10 +2379,12 @@ const deserializeAws_restJson1ListFeaturesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2404,8 +2421,7 @@ const deserializeAws_restJson1ListLaunchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2418,10 +2434,12 @@ const deserializeAws_restJson1ListLaunchesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2458,8 +2476,7 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2472,10 +2489,12 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2508,8 +2527,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.evidently#ConflictException": @@ -2522,10 +2540,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2562,8 +2582,7 @@ const deserializeAws_restJson1PutProjectEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2579,10 +2598,12 @@ const deserializeAws_restJson1PutProjectEventsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2615,8 +2636,7 @@ const deserializeAws_restJson1StartExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2638,10 +2658,12 @@ const deserializeAws_restJson1StartExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2674,8 +2696,7 @@ const deserializeAws_restJson1StartLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2697,10 +2718,12 @@ const deserializeAws_restJson1StartLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2733,8 +2756,7 @@ const deserializeAws_restJson1StopExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2756,10 +2778,12 @@ const deserializeAws_restJson1StopExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2792,8 +2816,7 @@ const deserializeAws_restJson1StopLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2809,10 +2832,12 @@ const deserializeAws_restJson1StopLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2841,8 +2866,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.evidently#ConflictException": @@ -2855,10 +2879,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2887,8 +2913,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.evidently#ConflictException": @@ -2901,10 +2926,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2937,8 +2964,7 @@ const deserializeAws_restJson1UpdateExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -2954,10 +2980,12 @@ const deserializeAws_restJson1UpdateExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2990,8 +3018,7 @@ const deserializeAws_restJson1UpdateFeatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -3010,10 +3037,12 @@ const deserializeAws_restJson1UpdateFeatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3046,8 +3075,7 @@ const deserializeAws_restJson1UpdateLaunchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -3063,10 +3091,12 @@ const deserializeAws_restJson1UpdateLaunchCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3099,8 +3129,7 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -3116,10 +3145,12 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3152,8 +3183,7 @@ const deserializeAws_restJson1UpdateProjectDataDeliveryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.evidently#AccessDeniedException": @@ -3172,10 +3202,12 @@ const deserializeAws_restJson1UpdateProjectDataDeliveryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4468,7 +4500,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4494,6 +4526,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-finspace-data/src/protocols/Aws_restJson1.ts b/clients/client-finspace-data/src/protocols/Aws_restJson1.ts index 51b8a6b069553..9899960325e61 100644 --- a/clients/client-finspace-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-finspace-data/src/protocols/Aws_restJson1.ts @@ -1158,8 +1158,7 @@ const deserializeAws_restJson1AssociateUserToPermissionGroupCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1181,10 +1180,12 @@ const deserializeAws_restJson1AssociateUserToPermissionGroupCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1221,8 +1222,7 @@ const deserializeAws_restJson1CreateChangesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1247,10 +1247,12 @@ const deserializeAws_restJson1CreateChangesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1283,8 +1285,7 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1309,10 +1310,12 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1352,7 @@ const deserializeAws_restJson1CreateDataViewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.finspacedata#ConflictException": @@ -1372,10 +1374,12 @@ const deserializeAws_restJson1CreateDataViewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1408,8 +1412,7 @@ const deserializeAws_restJson1CreatePermissionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1431,10 +1434,12 @@ const deserializeAws_restJson1CreatePermissionGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1467,8 +1472,7 @@ const deserializeAws_restJson1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1490,10 +1494,12 @@ const deserializeAws_restJson1CreateUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1526,8 +1532,7 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1552,10 +1557,12 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1588,8 +1595,7 @@ const deserializeAws_restJson1DeletePermissionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1614,10 +1620,12 @@ const deserializeAws_restJson1DeletePermissionGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1650,8 +1658,7 @@ const deserializeAws_restJson1DisableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1673,10 +1680,12 @@ const deserializeAws_restJson1DisableUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1709,8 +1718,7 @@ const deserializeAws_restJson1DisassociateUserFromPermissionGroupCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1732,10 +1740,12 @@ const deserializeAws_restJson1DisassociateUserFromPermissionGroupCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1778,7 @@ const deserializeAws_restJson1EnableUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1794,10 +1803,12 @@ const deserializeAws_restJson1EnableUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1878,8 +1889,7 @@ const deserializeAws_restJson1GetChangesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1901,10 +1911,12 @@ const deserializeAws_restJson1GetChangesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1973,8 +1985,7 @@ const deserializeAws_restJson1GetDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -1996,10 +2007,12 @@ const deserializeAws_restJson1GetDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2079,8 +2092,7 @@ const deserializeAws_restJson1GetDataViewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.finspacedata#ConflictException": @@ -2099,10 +2111,12 @@ const deserializeAws_restJson1GetDataViewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2135,8 +2149,7 @@ const deserializeAws_restJson1GetPermissionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2155,10 +2168,12 @@ const deserializeAws_restJson1GetPermissionGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2195,8 +2210,7 @@ const deserializeAws_restJson1GetProgrammaticAccessCredentialsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2212,10 +2226,12 @@ const deserializeAws_restJson1GetProgrammaticAccessCredentialsCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2296,8 +2312,7 @@ const deserializeAws_restJson1GetUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2316,10 +2331,12 @@ const deserializeAws_restJson1GetUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2360,8 +2377,7 @@ const deserializeAws_restJson1GetWorkingLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2377,10 +2393,12 @@ const deserializeAws_restJson1GetWorkingLocationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2417,8 +2435,7 @@ const deserializeAws_restJson1ListChangesetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2440,10 +2457,12 @@ const deserializeAws_restJson1ListChangesetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2499,7 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.finspacedata#ConflictException": @@ -2500,10 +2518,12 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2540,8 +2560,7 @@ const deserializeAws_restJson1ListDataViewsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.finspacedata#ConflictException": @@ -2560,10 +2579,12 @@ const deserializeAws_restJson1ListDataViewsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2600,8 +2621,7 @@ const deserializeAws_restJson1ListPermissionGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2617,10 +2637,12 @@ const deserializeAws_restJson1ListPermissionGroupsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2657,8 +2679,7 @@ const deserializeAws_restJson1ListPermissionGroupsByUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2677,10 +2698,12 @@ const deserializeAws_restJson1ListPermissionGroupsByUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2717,8 +2740,7 @@ const deserializeAws_restJson1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2734,10 +2756,12 @@ const deserializeAws_restJson1ListUsersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2774,8 +2798,7 @@ const deserializeAws_restJson1ListUsersByPermissionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2794,10 +2817,12 @@ const deserializeAws_restJson1ListUsersByPermissionGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2834,8 +2859,7 @@ const deserializeAws_restJson1ResetUserPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2857,10 +2881,12 @@ const deserializeAws_restJson1ResetUserPasswordCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2897,8 +2923,7 @@ const deserializeAws_restJson1UpdateChangesetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2920,10 +2945,12 @@ const deserializeAws_restJson1UpdateChangesetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2956,8 +2983,7 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -2979,10 +3005,12 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3015,8 +3043,7 @@ const deserializeAws_restJson1UpdatePermissionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -3038,10 +3065,12 @@ const deserializeAws_restJson1UpdatePermissionGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3074,8 +3103,7 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspacedata#AccessDeniedException": @@ -3097,10 +3125,12 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3842,7 +3872,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3868,6 +3898,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-finspace/src/protocols/Aws_restJson1.ts b/clients/client-finspace/src/protocols/Aws_restJson1.ts index 6810ae80b11e7..a0572d813fbb6 100644 --- a/clients/client-finspace/src/protocols/Aws_restJson1.ts +++ b/clients/client-finspace/src/protocols/Aws_restJson1.ts @@ -329,8 +329,7 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspace#AccessDeniedException": @@ -352,10 +351,12 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -384,8 +385,7 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspace#AccessDeniedException": @@ -404,10 +404,12 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -440,8 +442,7 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspace#AccessDeniedException": @@ -457,10 +458,12 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -497,8 +500,7 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.finspace#InternalServerException": @@ -508,10 +510,12 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -544,8 +548,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.finspace#InternalServerException": @@ -558,10 +561,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -590,8 +595,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.finspace#InternalServerException": @@ -604,10 +608,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -636,8 +642,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.finspace#InternalServerException": @@ -650,10 +655,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -686,8 +693,7 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.finspace#AccessDeniedException": @@ -706,10 +712,12 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1003,7 +1011,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1029,6 +1037,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-firehose/src/protocols/Aws_json1_1.ts b/clients/client-firehose/src/protocols/Aws_json1_1.ts index 9fcd8da40a821..ac1f9c8f058cb 100644 --- a/clients/client-firehose/src/protocols/Aws_json1_1.ts +++ b/clients/client-firehose/src/protocols/Aws_json1_1.ts @@ -337,8 +337,7 @@ const deserializeAws_json1_1CreateDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -354,10 +353,12 @@ const deserializeAws_json1_1CreateDeliveryStreamCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -389,8 +390,7 @@ const deserializeAws_json1_1DeleteDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.firehose#ResourceInUseException": @@ -400,10 +400,12 @@ const deserializeAws_json1_1DeleteDeliveryStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -435,18 +437,19 @@ const deserializeAws_json1_1DescribeDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.firehose#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -478,15 +481,16 @@ const deserializeAws_json1_1ListDeliveryStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -518,8 +522,7 @@ const deserializeAws_json1_1ListTagsForDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -532,10 +535,12 @@ const deserializeAws_json1_1ListTagsForDeliveryStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -567,8 +572,7 @@ const deserializeAws_json1_1PutRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -584,10 +588,12 @@ const deserializeAws_json1_1PutRecordCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -619,8 +625,7 @@ const deserializeAws_json1_1PutRecordBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -636,10 +641,12 @@ const deserializeAws_json1_1PutRecordBatchCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -671,8 +678,7 @@ const deserializeAws_json1_1StartDeliveryStreamEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -691,10 +697,12 @@ const deserializeAws_json1_1StartDeliveryStreamEncryptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -726,8 +734,7 @@ const deserializeAws_json1_1StopDeliveryStreamEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -743,10 +750,12 @@ const deserializeAws_json1_1StopDeliveryStreamEncryptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -778,8 +787,7 @@ const deserializeAws_json1_1TagDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -795,10 +803,12 @@ const deserializeAws_json1_1TagDeliveryStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -830,8 +840,7 @@ const deserializeAws_json1_1UntagDeliveryStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.firehose#InvalidArgumentException": @@ -847,10 +856,12 @@ const deserializeAws_json1_1UntagDeliveryStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -882,8 +893,7 @@ const deserializeAws_json1_1UpdateDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.firehose#ConcurrentModificationException": @@ -899,10 +909,12 @@ const deserializeAws_json1_1UpdateDestinationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3393,7 +3405,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3419,6 +3431,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-fis/src/protocols/Aws_restJson1.ts b/clients/client-fis/src/protocols/Aws_restJson1.ts index a0474a5f29916..e23fe8743eff9 100644 --- a/clients/client-fis/src/protocols/Aws_restJson1.ts +++ b/clients/client-fis/src/protocols/Aws_restJson1.ts @@ -624,8 +624,7 @@ const deserializeAws_restJson1CreateExperimentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.fis#ConflictException": @@ -641,10 +640,12 @@ const deserializeAws_restJson1CreateExperimentTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -677,8 +678,7 @@ const deserializeAws_restJson1DeleteExperimentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -688,10 +688,12 @@ const deserializeAws_restJson1DeleteExperimentTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -724,8 +726,7 @@ const deserializeAws_restJson1GetActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -735,10 +736,12 @@ const deserializeAws_restJson1GetActionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -771,8 +774,7 @@ const deserializeAws_restJson1GetExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -782,10 +784,12 @@ const deserializeAws_restJson1GetExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -818,8 +822,7 @@ const deserializeAws_restJson1GetExperimentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -829,10 +832,12 @@ const deserializeAws_restJson1GetExperimentTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -865,8 +870,7 @@ const deserializeAws_restJson1GetTargetResourceTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -876,10 +880,12 @@ const deserializeAws_restJson1GetTargetResourceTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -916,18 +922,19 @@ const deserializeAws_restJson1ListActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.fis#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -964,18 +971,19 @@ const deserializeAws_restJson1ListExperimentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.fis#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1015,18 +1023,19 @@ const deserializeAws_restJson1ListExperimentTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.fis#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1059,15 +1068,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1107,18 +1117,19 @@ const deserializeAws_restJson1ListTargetResourceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.fis#ValidationException": throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1151,8 +1162,7 @@ const deserializeAws_restJson1StartExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.fis#ConflictException": @@ -1168,10 +1178,12 @@ const deserializeAws_restJson1StartExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1204,8 +1216,7 @@ const deserializeAws_restJson1StopExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -1215,10 +1226,12 @@ const deserializeAws_restJson1StopExperimentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1247,15 +1260,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1284,15 +1298,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1325,8 +1340,7 @@ const deserializeAws_restJson1UpdateExperimentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.fis#ResourceNotFoundException": @@ -1339,10 +1353,12 @@ const deserializeAws_restJson1UpdateExperimentTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2662,7 +2678,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2688,6 +2704,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-fms/src/protocols/Aws_json1_1.ts b/clients/client-fms/src/protocols/Aws_json1_1.ts index d0432099b7080..206134dce2ae8 100644 --- a/clients/client-fms/src/protocols/Aws_json1_1.ts +++ b/clients/client-fms/src/protocols/Aws_json1_1.ts @@ -633,8 +633,7 @@ const deserializeAws_json1_1AssociateAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -653,10 +652,12 @@ const deserializeAws_json1_1AssociateAdminAccountCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -688,8 +689,7 @@ const deserializeAws_json1_1AssociateThirdPartyFirewallCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -705,10 +705,12 @@ const deserializeAws_json1_1AssociateThirdPartyFirewallCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -737,8 +739,7 @@ const deserializeAws_json1_1DeleteAppsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -751,10 +752,12 @@ const deserializeAws_json1_1DeleteAppsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -783,8 +786,7 @@ const deserializeAws_json1_1DeleteNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -797,10 +799,12 @@ const deserializeAws_json1_1DeleteNotificationChannelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -829,8 +833,7 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -849,10 +852,12 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -881,8 +886,7 @@ const deserializeAws_json1_1DeleteProtocolsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -895,10 +899,12 @@ const deserializeAws_json1_1DeleteProtocolsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -927,8 +933,7 @@ const deserializeAws_json1_1DisassociateAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -941,10 +946,12 @@ const deserializeAws_json1_1DisassociateAdminAccountCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -976,8 +983,7 @@ const deserializeAws_json1_1DisassociateThirdPartyFirewallCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -993,10 +999,12 @@ const deserializeAws_json1_1DisassociateThirdPartyFirewallCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1028,8 +1036,7 @@ const deserializeAws_json1_1GetAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1042,10 +1049,12 @@ const deserializeAws_json1_1GetAdminAccountCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1077,8 +1086,7 @@ const deserializeAws_json1_1GetAppsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1091,10 +1099,12 @@ const deserializeAws_json1_1GetAppsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1126,8 +1136,7 @@ const deserializeAws_json1_1GetComplianceDetailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1143,10 +1152,12 @@ const deserializeAws_json1_1GetComplianceDetailCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1178,8 +1189,7 @@ const deserializeAws_json1_1GetNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1192,10 +1202,12 @@ const deserializeAws_json1_1GetNotificationChannelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1227,8 +1239,7 @@ const deserializeAws_json1_1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1244,10 +1255,12 @@ const deserializeAws_json1_1GetPolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1279,8 +1292,7 @@ const deserializeAws_json1_1GetProtectionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1293,10 +1305,12 @@ const deserializeAws_json1_1GetProtectionStatusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1328,8 +1342,7 @@ const deserializeAws_json1_1GetProtocolsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1342,10 +1355,12 @@ const deserializeAws_json1_1GetProtocolsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1377,8 +1392,7 @@ const deserializeAws_json1_1GetThirdPartyFirewallAssociationStatusCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1394,10 +1408,12 @@ const deserializeAws_json1_1GetThirdPartyFirewallAssociationStatusCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1429,8 +1445,7 @@ const deserializeAws_json1_1GetViolationDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1443,10 +1458,12 @@ const deserializeAws_json1_1GetViolationDetailsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1495,7 @@ const deserializeAws_json1_1ListAppsListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1495,10 +1511,12 @@ const deserializeAws_json1_1ListAppsListsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1530,8 +1548,7 @@ const deserializeAws_json1_1ListComplianceStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1541,10 +1558,12 @@ const deserializeAws_json1_1ListComplianceStatusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1576,8 +1595,7 @@ const deserializeAws_json1_1ListMemberAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1587,10 +1605,12 @@ const deserializeAws_json1_1ListMemberAccountsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1622,8 +1642,7 @@ const deserializeAws_json1_1ListPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1639,10 +1658,12 @@ const deserializeAws_json1_1ListPoliciesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1674,8 +1695,7 @@ const deserializeAws_json1_1ListProtocolsListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1688,10 +1708,12 @@ const deserializeAws_json1_1ListProtocolsListsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1745,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1740,10 +1761,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1775,8 +1798,7 @@ const deserializeAws_json1_1ListThirdPartyFirewallFirewallPoliciesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1792,10 +1814,12 @@ const deserializeAws_json1_1ListThirdPartyFirewallFirewallPoliciesCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1827,8 +1851,7 @@ const deserializeAws_json1_1PutAppsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1847,10 +1870,12 @@ const deserializeAws_json1_1PutAppsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1879,8 +1904,7 @@ const deserializeAws_json1_1PutNotificationChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1893,10 +1917,12 @@ const deserializeAws_json1_1PutNotificationChannelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1928,8 +1954,7 @@ const deserializeAws_json1_1PutPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -1951,10 +1976,12 @@ const deserializeAws_json1_1PutPolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1986,8 +2013,7 @@ const deserializeAws_json1_1PutProtocolsListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -2006,10 +2032,12 @@ const deserializeAws_json1_1PutProtocolsListCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2041,8 +2069,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -2061,10 +2088,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2096,8 +2125,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.fms#InternalErrorException": @@ -2113,10 +2141,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4636,7 +4666,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4662,6 +4692,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-forecast/src/protocols/Aws_json1_1.ts b/clients/client-forecast/src/protocols/Aws_json1_1.ts index 03b979339893f..e0082e4e2b7c3 100644 --- a/clients/client-forecast/src/protocols/Aws_json1_1.ts +++ b/clients/client-forecast/src/protocols/Aws_json1_1.ts @@ -989,8 +989,7 @@ const deserializeAws_json1_1CreateAutoPredictorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1009,10 +1008,12 @@ const deserializeAws_json1_1CreateAutoPredictorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1044,8 +1045,7 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1058,10 +1058,12 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1095,7 @@ const deserializeAws_json1_1CreateDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1113,10 +1114,12 @@ const deserializeAws_json1_1CreateDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1148,8 +1151,7 @@ const deserializeAws_json1_1CreateDatasetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1168,10 +1170,12 @@ const deserializeAws_json1_1CreateDatasetImportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1203,8 +1207,7 @@ const deserializeAws_json1_1CreateExplainabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1223,10 +1226,12 @@ const deserializeAws_json1_1CreateExplainabilityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1258,8 +1263,7 @@ const deserializeAws_json1_1CreateExplainabilityExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1278,10 +1282,12 @@ const deserializeAws_json1_1CreateExplainabilityExportCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1313,8 +1319,7 @@ const deserializeAws_json1_1CreateForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1333,10 +1338,12 @@ const deserializeAws_json1_1CreateForecastCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1368,8 +1375,7 @@ const deserializeAws_json1_1CreateForecastExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1388,10 +1394,12 @@ const deserializeAws_json1_1CreateForecastExportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1423,8 +1431,7 @@ const deserializeAws_json1_1CreateMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1443,10 +1450,12 @@ const deserializeAws_json1_1CreateMonitorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1487,7 @@ const deserializeAws_json1_1CreatePredictorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1498,10 +1506,12 @@ const deserializeAws_json1_1CreatePredictorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1533,8 +1543,7 @@ const deserializeAws_json1_1CreatePredictorBacktestExportJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1553,10 +1562,12 @@ const deserializeAws_json1_1CreatePredictorBacktestExportJobCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1585,8 +1596,7 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1599,10 +1609,12 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1643,7 @@ const deserializeAws_json1_1DeleteDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1645,10 +1656,12 @@ const deserializeAws_json1_1DeleteDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,8 +1690,7 @@ const deserializeAws_json1_1DeleteDatasetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1691,10 +1703,12 @@ const deserializeAws_json1_1DeleteDatasetImportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1737,7 @@ const deserializeAws_json1_1DeleteExplainabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1737,10 +1750,12 @@ const deserializeAws_json1_1DeleteExplainabilityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1769,8 +1784,7 @@ const deserializeAws_json1_1DeleteExplainabilityExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1783,10 +1797,12 @@ const deserializeAws_json1_1DeleteExplainabilityExportCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1815,8 +1831,7 @@ const deserializeAws_json1_1DeleteForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1829,10 +1844,12 @@ const deserializeAws_json1_1DeleteForecastCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1861,8 +1878,7 @@ const deserializeAws_json1_1DeleteForecastExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1875,10 +1891,12 @@ const deserializeAws_json1_1DeleteForecastExportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1907,8 +1925,7 @@ const deserializeAws_json1_1DeleteMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1921,10 +1938,12 @@ const deserializeAws_json1_1DeleteMonitorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,8 +1972,7 @@ const deserializeAws_json1_1DeletePredictorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -1967,10 +1985,12 @@ const deserializeAws_json1_1DeletePredictorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1999,8 +2019,7 @@ const deserializeAws_json1_1DeletePredictorBacktestExportJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2013,10 +2032,12 @@ const deserializeAws_json1_1DeletePredictorBacktestExportJobCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2066,7 @@ const deserializeAws_json1_1DeleteResourceTreeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2059,10 +2079,12 @@ const deserializeAws_json1_1DeleteResourceTreeCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2094,8 +2116,7 @@ const deserializeAws_json1_1DescribeAutoPredictorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2105,10 +2126,12 @@ const deserializeAws_json1_1DescribeAutoPredictorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2140,8 +2163,7 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2151,10 +2173,12 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2186,8 +2210,7 @@ const deserializeAws_json1_1DescribeDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2197,10 +2220,12 @@ const deserializeAws_json1_1DescribeDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2232,8 +2257,7 @@ const deserializeAws_json1_1DescribeDatasetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2243,10 +2267,12 @@ const deserializeAws_json1_1DescribeDatasetImportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2278,8 +2304,7 @@ const deserializeAws_json1_1DescribeExplainabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2289,10 +2314,12 @@ const deserializeAws_json1_1DescribeExplainabilityCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2324,8 +2351,7 @@ const deserializeAws_json1_1DescribeExplainabilityExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2335,10 +2361,12 @@ const deserializeAws_json1_1DescribeExplainabilityExportCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2370,8 +2398,7 @@ const deserializeAws_json1_1DescribeForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2381,10 +2408,12 @@ const deserializeAws_json1_1DescribeForecastCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2416,8 +2445,7 @@ const deserializeAws_json1_1DescribeForecastExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2427,10 +2455,12 @@ const deserializeAws_json1_1DescribeForecastExportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2462,8 +2492,7 @@ const deserializeAws_json1_1DescribeMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2473,10 +2502,12 @@ const deserializeAws_json1_1DescribeMonitorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2508,8 +2539,7 @@ const deserializeAws_json1_1DescribePredictorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2519,10 +2549,12 @@ const deserializeAws_json1_1DescribePredictorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2554,8 +2586,7 @@ const deserializeAws_json1_1DescribePredictorBacktestExportJobCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2565,10 +2596,12 @@ const deserializeAws_json1_1DescribePredictorBacktestExportJobCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2600,8 +2633,7 @@ const deserializeAws_json1_1GetAccuracyMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2614,10 +2646,12 @@ const deserializeAws_json1_1GetAccuracyMetricsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2649,18 +2683,19 @@ const deserializeAws_json1_1ListDatasetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.forecast#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2692,8 +2727,7 @@ const deserializeAws_json1_1ListDatasetImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2703,10 +2737,12 @@ const deserializeAws_json1_1ListDatasetImportJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2738,18 +2774,19 @@ const deserializeAws_json1_1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.forecast#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2781,8 +2818,7 @@ const deserializeAws_json1_1ListExplainabilitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2792,10 +2828,12 @@ const deserializeAws_json1_1ListExplainabilitiesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2827,8 +2865,7 @@ const deserializeAws_json1_1ListExplainabilityExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2838,10 +2875,12 @@ const deserializeAws_json1_1ListExplainabilityExportsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2873,8 +2912,7 @@ const deserializeAws_json1_1ListForecastExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2884,10 +2922,12 @@ const deserializeAws_json1_1ListForecastExportJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2919,8 +2959,7 @@ const deserializeAws_json1_1ListForecastsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2930,10 +2969,12 @@ const deserializeAws_json1_1ListForecastsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2965,8 +3006,7 @@ const deserializeAws_json1_1ListMonitorEvaluationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -2979,10 +3019,12 @@ const deserializeAws_json1_1ListMonitorEvaluationsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3014,8 +3056,7 @@ const deserializeAws_json1_1ListMonitorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3025,10 +3066,12 @@ const deserializeAws_json1_1ListMonitorsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3060,8 +3103,7 @@ const deserializeAws_json1_1ListPredictorBacktestExportJobsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3071,10 +3113,12 @@ const deserializeAws_json1_1ListPredictorBacktestExportJobsCommandError = async throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3106,8 +3150,7 @@ const deserializeAws_json1_1ListPredictorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3117,10 +3160,12 @@ const deserializeAws_json1_1ListPredictorsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3152,8 +3197,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3163,10 +3207,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3195,8 +3241,7 @@ const deserializeAws_json1_1ResumeResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3212,10 +3257,12 @@ const deserializeAws_json1_1ResumeResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3244,8 +3291,7 @@ const deserializeAws_json1_1StopResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3258,10 +3304,12 @@ const deserializeAws_json1_1StopResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3293,8 +3341,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3307,10 +3354,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3342,8 +3391,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3353,10 +3401,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3388,8 +3438,7 @@ const deserializeAws_json1_1UpdateDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecast#InvalidInputException": @@ -3402,10 +3451,12 @@ const deserializeAws_json1_1UpdateDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6511,7 +6562,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6537,6 +6588,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-forecastquery/src/protocols/Aws_json1_1.ts b/clients/client-forecastquery/src/protocols/Aws_json1_1.ts index b5a02000f0228..2b24cb5ce7a5c 100644 --- a/clients/client-forecastquery/src/protocols/Aws_json1_1.ts +++ b/clients/client-forecastquery/src/protocols/Aws_json1_1.ts @@ -65,8 +65,7 @@ const deserializeAws_json1_1QueryForecastCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.forecastquery#InvalidInputException": @@ -85,10 +84,12 @@ const deserializeAws_json1_1QueryForecastCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -322,7 +323,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -348,6 +349,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-frauddetector/src/protocols/Aws_json1_1.ts b/clients/client-frauddetector/src/protocols/Aws_json1_1.ts index a0970efcb8734..d844e99e40d1e 100644 --- a/clients/client-frauddetector/src/protocols/Aws_json1_1.ts +++ b/clients/client-frauddetector/src/protocols/Aws_json1_1.ts @@ -1260,8 +1260,7 @@ const deserializeAws_json1_1BatchCreateVariableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1277,10 +1276,12 @@ const deserializeAws_json1_1BatchCreateVariableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1312,8 +1313,7 @@ const deserializeAws_json1_1BatchGetVariableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1329,10 +1329,12 @@ const deserializeAws_json1_1BatchGetVariableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1364,8 +1366,7 @@ const deserializeAws_json1_1CancelBatchImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1384,10 +1385,12 @@ const deserializeAws_json1_1CancelBatchImportJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1419,8 +1422,7 @@ const deserializeAws_json1_1CancelBatchPredictionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1439,10 +1441,12 @@ const deserializeAws_json1_1CancelBatchPredictionJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1474,8 +1478,7 @@ const deserializeAws_json1_1CreateBatchImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1494,10 +1497,12 @@ const deserializeAws_json1_1CreateBatchImportJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1529,8 +1534,7 @@ const deserializeAws_json1_1CreateBatchPredictionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1549,10 +1553,12 @@ const deserializeAws_json1_1CreateBatchPredictionJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1584,8 +1590,7 @@ const deserializeAws_json1_1CreateDetectorVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1604,10 +1609,12 @@ const deserializeAws_json1_1CreateDetectorVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1639,8 +1646,7 @@ const deserializeAws_json1_1CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1656,10 +1662,12 @@ const deserializeAws_json1_1CreateModelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1691,8 +1699,7 @@ const deserializeAws_json1_1CreateModelVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1711,10 +1718,12 @@ const deserializeAws_json1_1CreateModelVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1746,8 +1755,7 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1763,10 +1771,12 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1798,8 +1808,7 @@ const deserializeAws_json1_1CreateVariableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1815,10 +1824,12 @@ const deserializeAws_json1_1CreateVariableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1850,8 +1861,7 @@ const deserializeAws_json1_1DeleteBatchImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1867,10 +1877,12 @@ const deserializeAws_json1_1DeleteBatchImportJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1902,8 +1914,7 @@ const deserializeAws_json1_1DeleteBatchPredictionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1919,10 +1930,12 @@ const deserializeAws_json1_1DeleteBatchPredictionJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1954,8 +1967,7 @@ const deserializeAws_json1_1DeleteDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -1974,10 +1986,12 @@ const deserializeAws_json1_1DeleteDetectorCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2009,8 +2023,7 @@ const deserializeAws_json1_1DeleteDetectorVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2032,10 +2045,12 @@ const deserializeAws_json1_1DeleteDetectorVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2082,7 @@ const deserializeAws_json1_1DeleteEntityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2087,10 +2101,12 @@ const deserializeAws_json1_1DeleteEntityTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2122,8 +2138,7 @@ const deserializeAws_json1_1DeleteEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2139,10 +2154,12 @@ const deserializeAws_json1_1DeleteEventCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2174,8 +2191,7 @@ const deserializeAws_json1_1DeleteEventsByEventTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2197,10 +2213,12 @@ const deserializeAws_json1_1DeleteEventsByEventTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2232,8 +2250,7 @@ const deserializeAws_json1_1DeleteEventTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2252,10 +2269,12 @@ const deserializeAws_json1_1DeleteEventTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2287,8 +2306,7 @@ const deserializeAws_json1_1DeleteExternalModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2307,10 +2325,12 @@ const deserializeAws_json1_1DeleteExternalModelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2342,8 +2362,7 @@ const deserializeAws_json1_1DeleteLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.frauddetector#ConflictException": @@ -2359,10 +2378,12 @@ const deserializeAws_json1_1DeleteLabelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2394,8 +2415,7 @@ const deserializeAws_json1_1DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2414,10 +2434,12 @@ const deserializeAws_json1_1DeleteModelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2449,8 +2471,7 @@ const deserializeAws_json1_1DeleteModelVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2469,10 +2490,12 @@ const deserializeAws_json1_1DeleteModelVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2504,8 +2527,7 @@ const deserializeAws_json1_1DeleteOutcomeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2524,10 +2546,12 @@ const deserializeAws_json1_1DeleteOutcomeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2583,7 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2579,10 +2602,12 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2614,8 +2639,7 @@ const deserializeAws_json1_1DeleteVariableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2634,10 +2658,12 @@ const deserializeAws_json1_1DeleteVariableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2669,8 +2695,7 @@ const deserializeAws_json1_1DescribeDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2689,10 +2714,12 @@ const deserializeAws_json1_1DescribeDetectorCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2724,8 +2751,7 @@ const deserializeAws_json1_1DescribeModelVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2744,10 +2770,12 @@ const deserializeAws_json1_1DescribeModelVersionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2779,8 +2807,7 @@ const deserializeAws_json1_1GetBatchImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2799,10 +2826,12 @@ const deserializeAws_json1_1GetBatchImportJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2834,8 +2863,7 @@ const deserializeAws_json1_1GetBatchPredictionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2854,10 +2882,12 @@ const deserializeAws_json1_1GetBatchPredictionJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2889,8 +2919,7 @@ const deserializeAws_json1_1GetDeleteEventsByEventTypeStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2909,10 +2938,12 @@ const deserializeAws_json1_1GetDeleteEventsByEventTypeStatusCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2944,8 +2975,7 @@ const deserializeAws_json1_1GetDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -2964,10 +2994,12 @@ const deserializeAws_json1_1GetDetectorsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2999,8 +3031,7 @@ const deserializeAws_json1_1GetDetectorVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3019,10 +3050,12 @@ const deserializeAws_json1_1GetDetectorVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3054,8 +3087,7 @@ const deserializeAws_json1_1GetEntityTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3074,10 +3106,12 @@ const deserializeAws_json1_1GetEntityTypesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3109,8 +3143,7 @@ const deserializeAws_json1_1GetEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3129,10 +3162,12 @@ const deserializeAws_json1_1GetEventCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3164,8 +3199,7 @@ const deserializeAws_json1_1GetEventPredictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3190,10 +3224,12 @@ const deserializeAws_json1_1GetEventPredictionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3225,8 +3261,7 @@ const deserializeAws_json1_1GetEventPredictionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3245,10 +3280,12 @@ const deserializeAws_json1_1GetEventPredictionMetadataCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3280,8 +3317,7 @@ const deserializeAws_json1_1GetEventTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3300,10 +3336,12 @@ const deserializeAws_json1_1GetEventTypesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3335,8 +3373,7 @@ const deserializeAws_json1_1GetExternalModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3355,10 +3392,12 @@ const deserializeAws_json1_1GetExternalModelsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3390,8 +3429,7 @@ const deserializeAws_json1_1GetKMSEncryptionKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3407,10 +3445,12 @@ const deserializeAws_json1_1GetKMSEncryptionKeyCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3442,8 +3482,7 @@ const deserializeAws_json1_1GetLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3462,10 +3501,12 @@ const deserializeAws_json1_1GetLabelsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3497,8 +3538,7 @@ const deserializeAws_json1_1GetModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3517,10 +3557,12 @@ const deserializeAws_json1_1GetModelsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3552,8 +3594,7 @@ const deserializeAws_json1_1GetModelVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3572,10 +3613,12 @@ const deserializeAws_json1_1GetModelVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3607,8 +3650,7 @@ const deserializeAws_json1_1GetOutcomesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3627,10 +3669,12 @@ const deserializeAws_json1_1GetOutcomesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3662,8 +3706,7 @@ const deserializeAws_json1_1GetRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3682,10 +3725,12 @@ const deserializeAws_json1_1GetRulesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3717,8 +3762,7 @@ const deserializeAws_json1_1GetVariablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3737,10 +3781,12 @@ const deserializeAws_json1_1GetVariablesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3772,8 +3818,7 @@ const deserializeAws_json1_1ListEventPredictionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3789,10 +3834,12 @@ const deserializeAws_json1_1ListEventPredictionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3824,8 +3871,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3841,10 +3887,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3876,8 +3924,7 @@ const deserializeAws_json1_1PutDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3896,10 +3943,12 @@ const deserializeAws_json1_1PutDetectorCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3931,8 +3980,7 @@ const deserializeAws_json1_1PutEntityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -3951,10 +3999,12 @@ const deserializeAws_json1_1PutEntityTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3986,8 +4036,7 @@ const deserializeAws_json1_1PutEventTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4006,10 +4055,12 @@ const deserializeAws_json1_1PutEventTypeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4041,8 +4092,7 @@ const deserializeAws_json1_1PutExternalModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4061,10 +4111,12 @@ const deserializeAws_json1_1PutExternalModelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4096,8 +4148,7 @@ const deserializeAws_json1_1PutKMSEncryptionKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4119,10 +4170,12 @@ const deserializeAws_json1_1PutKMSEncryptionKeyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4154,8 +4207,7 @@ const deserializeAws_json1_1PutLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4174,10 +4226,12 @@ const deserializeAws_json1_1PutLabelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4209,8 +4263,7 @@ const deserializeAws_json1_1PutOutcomeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4229,10 +4282,12 @@ const deserializeAws_json1_1PutOutcomeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4264,8 +4319,7 @@ const deserializeAws_json1_1SendEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4287,10 +4341,12 @@ const deserializeAws_json1_1SendEventCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4322,8 +4378,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4339,10 +4394,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4374,8 +4431,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4391,10 +4447,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4426,8 +4484,7 @@ const deserializeAws_json1_1UpdateDetectorVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4449,10 +4506,12 @@ const deserializeAws_json1_1UpdateDetectorVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4484,8 +4543,7 @@ const deserializeAws_json1_1UpdateDetectorVersionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4504,10 +4562,12 @@ const deserializeAws_json1_1UpdateDetectorVersionMetadataCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4539,8 +4599,7 @@ const deserializeAws_json1_1UpdateDetectorVersionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4562,10 +4621,12 @@ const deserializeAws_json1_1UpdateDetectorVersionStatusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4597,8 +4658,7 @@ const deserializeAws_json1_1UpdateEventLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4620,10 +4680,12 @@ const deserializeAws_json1_1UpdateEventLabelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4655,8 +4717,7 @@ const deserializeAws_json1_1UpdateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4678,10 +4739,12 @@ const deserializeAws_json1_1UpdateModelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4713,8 +4776,7 @@ const deserializeAws_json1_1UpdateModelVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4736,10 +4798,12 @@ const deserializeAws_json1_1UpdateModelVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4771,8 +4835,7 @@ const deserializeAws_json1_1UpdateModelVersionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4794,10 +4857,12 @@ const deserializeAws_json1_1UpdateModelVersionStatusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4829,8 +4894,7 @@ const deserializeAws_json1_1UpdateRuleMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4852,10 +4916,12 @@ const deserializeAws_json1_1UpdateRuleMetadataCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4887,8 +4953,7 @@ const deserializeAws_json1_1UpdateRuleVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4910,10 +4975,12 @@ const deserializeAws_json1_1UpdateRuleVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4945,8 +5012,7 @@ const deserializeAws_json1_1UpdateVariableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.frauddetector#AccessDeniedException": @@ -4968,10 +5034,12 @@ const deserializeAws_json1_1UpdateVariableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7965,7 +8033,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7991,6 +8059,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-fsx/src/protocols/Aws_json1_1.ts b/clients/client-fsx/src/protocols/Aws_json1_1.ts index 31b8ef2b97e61..b1a7add43641f 100644 --- a/clients/client-fsx/src/protocols/Aws_json1_1.ts +++ b/clients/client-fsx/src/protocols/Aws_json1_1.ts @@ -816,8 +816,7 @@ const deserializeAws_json1_1AssociateFileSystemAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -830,10 +829,12 @@ const deserializeAws_json1_1AssociateFileSystemAliasesCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -865,8 +866,7 @@ const deserializeAws_json1_1CancelDataRepositoryTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -885,10 +885,12 @@ const deserializeAws_json1_1CancelDataRepositoryTaskCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -920,8 +922,7 @@ const deserializeAws_json1_1CopyBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupNotFound": case "com.amazonaws.fsx#BackupNotFound": @@ -958,10 +959,12 @@ const deserializeAws_json1_1CopyBackupCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -993,8 +996,7 @@ const deserializeAws_json1_1CreateBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupInProgress": case "com.amazonaws.fsx#BackupInProgress": @@ -1022,10 +1024,12 @@ const deserializeAws_json1_1CreateBackupCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1057,8 +1061,7 @@ const deserializeAws_json1_1CreateDataRepositoryAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1080,10 +1083,12 @@ const deserializeAws_json1_1CreateDataRepositoryAssociationCommandError = async throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1115,8 +1120,7 @@ const deserializeAws_json1_1CreateDataRepositoryTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1141,10 +1145,12 @@ const deserializeAws_json1_1CreateDataRepositoryTaskCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1176,8 +1182,7 @@ const deserializeAws_json1_1CreateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveDirectoryError": case "com.amazonaws.fsx#ActiveDirectoryError": @@ -1211,10 +1216,12 @@ const deserializeAws_json1_1CreateFileSystemCommandError = async ( throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1246,8 +1253,7 @@ const deserializeAws_json1_1CreateFileSystemFromBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveDirectoryError": case "com.amazonaws.fsx#ActiveDirectoryError": @@ -1278,10 +1284,12 @@ const deserializeAws_json1_1CreateFileSystemFromBackupCommandError = async ( throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1313,8 +1321,7 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1330,10 +1337,12 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1365,8 +1374,7 @@ const deserializeAws_json1_1CreateStorageVirtualMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveDirectoryError": case "com.amazonaws.fsx#ActiveDirectoryError": @@ -1391,10 +1399,12 @@ const deserializeAws_json1_1CreateStorageVirtualMachineCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1426,8 +1436,7 @@ const deserializeAws_json1_1CreateVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1455,10 +1464,12 @@ const deserializeAws_json1_1CreateVolumeCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1490,8 +1501,7 @@ const deserializeAws_json1_1CreateVolumeFromBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupNotFound": case "com.amazonaws.fsx#BackupNotFound": @@ -1519,10 +1529,12 @@ const deserializeAws_json1_1CreateVolumeFromBackupCommandError = async ( throw await deserializeAws_json1_1StorageVirtualMachineNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1554,8 +1566,7 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupBeingCopied": case "com.amazonaws.fsx#BackupBeingCopied": @@ -1580,10 +1591,12 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1615,8 +1628,7 @@ const deserializeAws_json1_1DeleteDataRepositoryAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1635,10 +1647,12 @@ const deserializeAws_json1_1DeleteDataRepositoryAssociationCommandError = async throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1670,8 +1684,7 @@ const deserializeAws_json1_1DeleteFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1690,10 +1703,12 @@ const deserializeAws_json1_1DeleteFileSystemCommandError = async ( throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1725,8 +1740,7 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1739,10 +1753,12 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( throw await deserializeAws_json1_1SnapshotNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1774,8 +1790,7 @@ const deserializeAws_json1_1DeleteStorageVirtualMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1791,10 +1806,12 @@ const deserializeAws_json1_1DeleteStorageVirtualMachineCommandError = async ( throw await deserializeAws_json1_1StorageVirtualMachineNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1843,7 @@ const deserializeAws_json1_1DeleteVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1843,10 +1859,12 @@ const deserializeAws_json1_1DeleteVolumeCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1878,8 +1896,7 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BackupNotFound": case "com.amazonaws.fsx#BackupNotFound": @@ -1898,10 +1915,12 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1933,8 +1952,7 @@ const deserializeAws_json1_1DescribeDataRepositoryAssociationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -1953,10 +1971,12 @@ const deserializeAws_json1_1DescribeDataRepositoryAssociationsCommandError = asy throw await deserializeAws_json1_1InvalidDataRepositoryTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1988,8 +2008,7 @@ const deserializeAws_json1_1DescribeDataRepositoryTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2005,10 +2024,12 @@ const deserializeAws_json1_1DescribeDataRepositoryTasksCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2040,8 +2061,7 @@ const deserializeAws_json1_1DescribeFileSystemAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2054,10 +2074,12 @@ const deserializeAws_json1_1DescribeFileSystemAliasesCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2089,8 +2111,7 @@ const deserializeAws_json1_1DescribeFileSystemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2103,10 +2124,12 @@ const deserializeAws_json1_1DescribeFileSystemsCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2138,8 +2161,7 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2152,10 +2174,12 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( throw await deserializeAws_json1_1SnapshotNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2187,8 +2211,7 @@ const deserializeAws_json1_1DescribeStorageVirtualMachinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2201,10 +2224,12 @@ const deserializeAws_json1_1DescribeStorageVirtualMachinesCommandError = async ( throw await deserializeAws_json1_1StorageVirtualMachineNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2236,8 +2261,7 @@ const deserializeAws_json1_1DescribeVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2250,10 +2274,12 @@ const deserializeAws_json1_1DescribeVolumesCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2285,8 +2311,7 @@ const deserializeAws_json1_1DisassociateFileSystemAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2299,10 +2324,12 @@ const deserializeAws_json1_1DisassociateFileSystemAliasesCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2334,8 +2361,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2354,10 +2380,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2389,8 +2417,7 @@ const deserializeAws_json1_1ReleaseFileSystemNfsV3LocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2409,10 +2436,12 @@ const deserializeAws_json1_1ReleaseFileSystemNfsV3LocksCommandError = async ( throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2444,8 +2473,7 @@ const deserializeAws_json1_1RestoreVolumeFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2458,10 +2486,12 @@ const deserializeAws_json1_1RestoreVolumeFromSnapshotCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2493,8 +2523,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2513,10 +2542,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2548,8 +2579,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2568,10 +2598,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2603,8 +2635,7 @@ const deserializeAws_json1_1UpdateDataRepositoryAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2623,10 +2654,12 @@ const deserializeAws_json1_1UpdateDataRepositoryAssociationCommandError = async throw await deserializeAws_json1_1ServiceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2658,8 +2691,7 @@ const deserializeAws_json1_1UpdateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2684,10 +2716,12 @@ const deserializeAws_json1_1UpdateFileSystemCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2719,8 +2753,7 @@ const deserializeAws_json1_1UpdateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2733,10 +2766,12 @@ const deserializeAws_json1_1UpdateSnapshotCommandError = async ( throw await deserializeAws_json1_1SnapshotNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2768,8 +2803,7 @@ const deserializeAws_json1_1UpdateStorageVirtualMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2788,10 +2822,12 @@ const deserializeAws_json1_1UpdateStorageVirtualMachineCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2823,8 +2859,7 @@ const deserializeAws_json1_1UpdateVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequest": case "com.amazonaws.fsx#BadRequest": @@ -2843,10 +2878,12 @@ const deserializeAws_json1_1UpdateVolumeCommandError = async ( throw await deserializeAws_json1_1VolumeNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6787,7 +6824,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6813,6 +6850,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-gamelift/src/protocols/Aws_json1_1.ts b/clients/client-gamelift/src/protocols/Aws_json1_1.ts index ea2396e629a0c..1f131bef63480 100644 --- a/clients/client-gamelift/src/protocols/Aws_json1_1.ts +++ b/clients/client-gamelift/src/protocols/Aws_json1_1.ts @@ -1809,8 +1809,7 @@ const deserializeAws_json1_1AcceptMatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -1826,10 +1825,12 @@ const deserializeAws_json1_1AcceptMatchCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1861,8 +1862,7 @@ const deserializeAws_json1_1ClaimGameServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -1884,10 +1884,12 @@ const deserializeAws_json1_1ClaimGameServerCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1919,8 +1921,7 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -1942,10 +1943,12 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1980,7 @@ const deserializeAws_json1_1CreateBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -1997,10 +1999,12 @@ const deserializeAws_json1_1CreateBuildCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2032,8 +2036,7 @@ const deserializeAws_json1_1CreateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -2061,10 +2064,12 @@ const deserializeAws_json1_1CreateFleetCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2096,8 +2101,7 @@ const deserializeAws_json1_1CreateFleetLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2119,10 +2123,12 @@ const deserializeAws_json1_1CreateFleetLocationsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2154,8 +2160,7 @@ const deserializeAws_json1_1CreateGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -2174,10 +2179,12 @@ const deserializeAws_json1_1CreateGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2209,8 +2216,7 @@ const deserializeAws_json1_1CreateGameSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -2247,10 +2253,12 @@ const deserializeAws_json1_1CreateGameSessionCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2282,8 +2290,7 @@ const deserializeAws_json1_1CreateGameSessionQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2305,10 +2312,12 @@ const deserializeAws_json1_1CreateGameSessionQueueCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2340,8 +2349,7 @@ const deserializeAws_json1_1CreateMatchmakingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2363,10 +2371,12 @@ const deserializeAws_json1_1CreateMatchmakingConfigurationCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2398,8 +2408,7 @@ const deserializeAws_json1_1CreateMatchmakingRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2415,10 +2424,12 @@ const deserializeAws_json1_1CreateMatchmakingRuleSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2450,8 +2461,7 @@ const deserializeAws_json1_1CreatePlayerSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GameSessionFullException": case "com.amazonaws.gamelift#GameSessionFullException": @@ -2476,10 +2486,12 @@ const deserializeAws_json1_1CreatePlayerSessionCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2511,8 +2523,7 @@ const deserializeAws_json1_1CreatePlayerSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GameSessionFullException": case "com.amazonaws.gamelift#GameSessionFullException": @@ -2537,10 +2548,12 @@ const deserializeAws_json1_1CreatePlayerSessionsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2572,8 +2585,7 @@ const deserializeAws_json1_1CreateScriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -2592,10 +2604,12 @@ const deserializeAws_json1_1CreateScriptCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2627,8 +2641,7 @@ const deserializeAws_json1_1CreateVpcPeeringAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2644,10 +2657,12 @@ const deserializeAws_json1_1CreateVpcPeeringAuthorizationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2679,8 +2694,7 @@ const deserializeAws_json1_1CreateVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2696,10 +2710,12 @@ const deserializeAws_json1_1CreateVpcPeeringConnectionCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2728,8 +2744,7 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2748,10 +2763,12 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2780,8 +2797,7 @@ const deserializeAws_json1_1DeleteBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2800,10 +2816,12 @@ const deserializeAws_json1_1DeleteBuildCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2832,8 +2850,7 @@ const deserializeAws_json1_1DeleteFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2855,10 +2872,12 @@ const deserializeAws_json1_1DeleteFleetCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2890,8 +2909,7 @@ const deserializeAws_json1_1DeleteFleetLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2910,10 +2928,12 @@ const deserializeAws_json1_1DeleteFleetLocationsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2945,8 +2965,7 @@ const deserializeAws_json1_1DeleteGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -2962,10 +2981,12 @@ const deserializeAws_json1_1DeleteGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2997,8 +3018,7 @@ const deserializeAws_json1_1DeleteGameSessionQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3017,10 +3037,12 @@ const deserializeAws_json1_1DeleteGameSessionQueueCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3052,8 +3074,7 @@ const deserializeAws_json1_1DeleteMatchmakingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3072,10 +3093,12 @@ const deserializeAws_json1_1DeleteMatchmakingConfigurationCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3107,8 +3130,7 @@ const deserializeAws_json1_1DeleteMatchmakingRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3127,10 +3149,12 @@ const deserializeAws_json1_1DeleteMatchmakingRuleSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3159,8 +3183,7 @@ const deserializeAws_json1_1DeleteScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3176,10 +3199,12 @@ const deserializeAws_json1_1DeleteScalingPolicyCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3208,8 +3233,7 @@ const deserializeAws_json1_1DeleteScriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3228,10 +3252,12 @@ const deserializeAws_json1_1DeleteScriptCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3263,8 +3289,7 @@ const deserializeAws_json1_1DeleteVpcPeeringAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3280,10 +3305,12 @@ const deserializeAws_json1_1DeleteVpcPeeringAuthorizationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3315,8 +3342,7 @@ const deserializeAws_json1_1DeleteVpcPeeringConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3332,10 +3358,12 @@ const deserializeAws_json1_1DeleteVpcPeeringConnectionCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3364,8 +3392,7 @@ const deserializeAws_json1_1DeregisterGameServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3381,10 +3408,12 @@ const deserializeAws_json1_1DeregisterGameServerCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3416,8 +3445,7 @@ const deserializeAws_json1_1DescribeAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3433,10 +3461,12 @@ const deserializeAws_json1_1DescribeAliasCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3468,8 +3498,7 @@ const deserializeAws_json1_1DescribeBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3485,10 +3514,12 @@ const deserializeAws_json1_1DescribeBuildCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3520,8 +3551,7 @@ const deserializeAws_json1_1DescribeEC2InstanceLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3537,10 +3567,12 @@ const deserializeAws_json1_1DescribeEC2InstanceLimitsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3572,8 +3604,7 @@ const deserializeAws_json1_1DescribeFleetAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3589,10 +3620,12 @@ const deserializeAws_json1_1DescribeFleetAttributesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3624,8 +3657,7 @@ const deserializeAws_json1_1DescribeFleetCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3641,10 +3673,12 @@ const deserializeAws_json1_1DescribeFleetCapacityCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3676,8 +3710,7 @@ const deserializeAws_json1_1DescribeFleetEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3693,10 +3726,12 @@ const deserializeAws_json1_1DescribeFleetEventsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3728,8 +3763,7 @@ const deserializeAws_json1_1DescribeFleetLocationAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3748,10 +3782,12 @@ const deserializeAws_json1_1DescribeFleetLocationAttributesCommandError = async throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3783,8 +3819,7 @@ const deserializeAws_json1_1DescribeFleetLocationCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3803,10 +3838,12 @@ const deserializeAws_json1_1DescribeFleetLocationCapacityCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3838,8 +3875,7 @@ const deserializeAws_json1_1DescribeFleetLocationUtilizationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3858,10 +3894,12 @@ const deserializeAws_json1_1DescribeFleetLocationUtilizationCommandError = async throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3893,8 +3931,7 @@ const deserializeAws_json1_1DescribeFleetPortSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3910,10 +3947,12 @@ const deserializeAws_json1_1DescribeFleetPortSettingsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3945,8 +3984,7 @@ const deserializeAws_json1_1DescribeFleetUtilizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -3962,10 +4000,12 @@ const deserializeAws_json1_1DescribeFleetUtilizationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3997,8 +4037,7 @@ const deserializeAws_json1_1DescribeGameServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4014,10 +4053,12 @@ const deserializeAws_json1_1DescribeGameServerCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4049,8 +4090,7 @@ const deserializeAws_json1_1DescribeGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4066,10 +4106,12 @@ const deserializeAws_json1_1DescribeGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4101,8 +4143,7 @@ const deserializeAws_json1_1DescribeGameServerInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4118,10 +4159,12 @@ const deserializeAws_json1_1DescribeGameServerInstancesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4153,8 +4196,7 @@ const deserializeAws_json1_1DescribeGameSessionDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4176,10 +4218,12 @@ const deserializeAws_json1_1DescribeGameSessionDetailsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4211,8 +4255,7 @@ const deserializeAws_json1_1DescribeGameSessionPlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4228,10 +4271,12 @@ const deserializeAws_json1_1DescribeGameSessionPlacementCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4263,8 +4308,7 @@ const deserializeAws_json1_1DescribeGameSessionQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4280,10 +4324,12 @@ const deserializeAws_json1_1DescribeGameSessionQueuesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4315,8 +4361,7 @@ const deserializeAws_json1_1DescribeGameSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4338,10 +4383,12 @@ const deserializeAws_json1_1DescribeGameSessionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4373,8 +4420,7 @@ const deserializeAws_json1_1DescribeInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4393,10 +4439,12 @@ const deserializeAws_json1_1DescribeInstancesCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4428,8 +4476,7 @@ const deserializeAws_json1_1DescribeMatchmakingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4442,10 +4489,12 @@ const deserializeAws_json1_1DescribeMatchmakingCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4477,8 +4526,7 @@ const deserializeAws_json1_1DescribeMatchmakingConfigurationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4491,10 +4539,12 @@ const deserializeAws_json1_1DescribeMatchmakingConfigurationsCommandError = asyn throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4526,8 +4576,7 @@ const deserializeAws_json1_1DescribeMatchmakingRuleSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4543,10 +4592,12 @@ const deserializeAws_json1_1DescribeMatchmakingRuleSetsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4578,8 +4629,7 @@ const deserializeAws_json1_1DescribePlayerSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4595,10 +4645,12 @@ const deserializeAws_json1_1DescribePlayerSessionsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4630,8 +4682,7 @@ const deserializeAws_json1_1DescribeRuntimeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4647,10 +4698,12 @@ const deserializeAws_json1_1DescribeRuntimeConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4682,8 +4735,7 @@ const deserializeAws_json1_1DescribeScalingPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4702,10 +4754,12 @@ const deserializeAws_json1_1DescribeScalingPoliciesCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4737,8 +4791,7 @@ const deserializeAws_json1_1DescribeScriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4754,10 +4807,12 @@ const deserializeAws_json1_1DescribeScriptCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4789,8 +4844,7 @@ const deserializeAws_json1_1DescribeVpcPeeringAuthorizationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4803,10 +4857,12 @@ const deserializeAws_json1_1DescribeVpcPeeringAuthorizationsCommandError = async throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4838,8 +4894,7 @@ const deserializeAws_json1_1DescribeVpcPeeringConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4855,10 +4910,12 @@ const deserializeAws_json1_1DescribeVpcPeeringConnectionsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4890,8 +4947,7 @@ const deserializeAws_json1_1GetGameSessionLogUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4907,10 +4963,12 @@ const deserializeAws_json1_1GetGameSessionLogUrlCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4942,8 +5000,7 @@ const deserializeAws_json1_1GetInstanceAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -4959,10 +5016,12 @@ const deserializeAws_json1_1GetInstanceAccessCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4994,8 +5053,7 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5008,10 +5066,12 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5043,8 +5103,7 @@ const deserializeAws_json1_1ListBuildsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5057,10 +5116,12 @@ const deserializeAws_json1_1ListBuildsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5092,8 +5153,7 @@ const deserializeAws_json1_1ListFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5109,10 +5169,12 @@ const deserializeAws_json1_1ListFleetsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5144,8 +5206,7 @@ const deserializeAws_json1_1ListGameServerGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5158,10 +5219,12 @@ const deserializeAws_json1_1ListGameServerGroupsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5193,8 +5256,7 @@ const deserializeAws_json1_1ListGameServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5207,10 +5269,12 @@ const deserializeAws_json1_1ListGameServersCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5242,8 +5306,7 @@ const deserializeAws_json1_1ListScriptsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5256,10 +5319,12 @@ const deserializeAws_json1_1ListScriptsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5291,8 +5356,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5308,10 +5372,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TaggingFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5343,8 +5409,7 @@ const deserializeAws_json1_1PutScalingPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5360,10 +5425,12 @@ const deserializeAws_json1_1PutScalingPolicyCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5395,8 +5462,7 @@ const deserializeAws_json1_1RegisterGameServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -5415,10 +5481,12 @@ const deserializeAws_json1_1RegisterGameServerCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5450,8 +5518,7 @@ const deserializeAws_json1_1RequestUploadCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5467,10 +5534,12 @@ const deserializeAws_json1_1RequestUploadCredentialsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5502,8 +5571,7 @@ const deserializeAws_json1_1ResolveAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5522,10 +5590,12 @@ const deserializeAws_json1_1ResolveAliasCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5557,8 +5627,7 @@ const deserializeAws_json1_1ResumeGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5574,10 +5643,12 @@ const deserializeAws_json1_1ResumeGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5609,8 +5680,7 @@ const deserializeAws_json1_1SearchGameSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5632,10 +5702,12 @@ const deserializeAws_json1_1SearchGameSessionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5667,8 +5739,7 @@ const deserializeAws_json1_1StartFleetActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5687,10 +5758,12 @@ const deserializeAws_json1_1StartFleetActionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5722,8 +5795,7 @@ const deserializeAws_json1_1StartGameSessionPlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5739,10 +5811,12 @@ const deserializeAws_json1_1StartGameSessionPlacementCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5774,8 +5848,7 @@ const deserializeAws_json1_1StartMatchBackfillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5791,10 +5864,12 @@ const deserializeAws_json1_1StartMatchBackfillCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5826,8 +5901,7 @@ const deserializeAws_json1_1StartMatchmakingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5843,10 +5917,12 @@ const deserializeAws_json1_1StartMatchmakingCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5878,8 +5954,7 @@ const deserializeAws_json1_1StopFleetActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5898,10 +5973,12 @@ const deserializeAws_json1_1StopFleetActionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5933,8 +6010,7 @@ const deserializeAws_json1_1StopGameSessionPlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -5950,10 +6026,12 @@ const deserializeAws_json1_1StopGameSessionPlacementCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5985,8 +6063,7 @@ const deserializeAws_json1_1StopMatchmakingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6002,10 +6079,12 @@ const deserializeAws_json1_1StopMatchmakingCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6037,8 +6116,7 @@ const deserializeAws_json1_1SuspendGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6054,10 +6132,12 @@ const deserializeAws_json1_1SuspendGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6089,8 +6169,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6106,10 +6185,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TaggingFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6141,8 +6222,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6158,10 +6238,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TaggingFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6193,8 +6275,7 @@ const deserializeAws_json1_1UpdateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6210,10 +6291,12 @@ const deserializeAws_json1_1UpdateAliasCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6245,8 +6328,7 @@ const deserializeAws_json1_1UpdateBuildCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6262,10 +6344,12 @@ const deserializeAws_json1_1UpdateBuildCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6297,8 +6381,7 @@ const deserializeAws_json1_1UpdateFleetAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -6323,10 +6406,12 @@ const deserializeAws_json1_1UpdateFleetAttributesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6358,8 +6443,7 @@ const deserializeAws_json1_1UpdateFleetCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -6387,10 +6471,12 @@ const deserializeAws_json1_1UpdateFleetCapacityCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6422,8 +6508,7 @@ const deserializeAws_json1_1UpdateFleetPortSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -6448,10 +6533,12 @@ const deserializeAws_json1_1UpdateFleetPortSettingsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6483,8 +6570,7 @@ const deserializeAws_json1_1UpdateGameServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6500,10 +6586,12 @@ const deserializeAws_json1_1UpdateGameServerCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6535,8 +6623,7 @@ const deserializeAws_json1_1UpdateGameServerGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6552,10 +6639,12 @@ const deserializeAws_json1_1UpdateGameServerGroupCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6587,8 +6676,7 @@ const deserializeAws_json1_1UpdateGameSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.gamelift#ConflictException": @@ -6610,10 +6698,12 @@ const deserializeAws_json1_1UpdateGameSessionCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6645,8 +6735,7 @@ const deserializeAws_json1_1UpdateGameSessionQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6662,10 +6751,12 @@ const deserializeAws_json1_1UpdateGameSessionQueueCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6697,8 +6788,7 @@ const deserializeAws_json1_1UpdateMatchmakingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6714,10 +6804,12 @@ const deserializeAws_json1_1UpdateMatchmakingConfigurationCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6749,8 +6841,7 @@ const deserializeAws_json1_1UpdateRuntimeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6769,10 +6860,12 @@ const deserializeAws_json1_1UpdateRuntimeConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6804,8 +6897,7 @@ const deserializeAws_json1_1UpdateScriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6821,10 +6913,12 @@ const deserializeAws_json1_1UpdateScriptCommandError = async ( throw await deserializeAws_json1_1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6856,8 +6950,7 @@ const deserializeAws_json1_1ValidateMatchmakingRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.gamelift#InternalServiceException": @@ -6870,10 +6963,12 @@ const deserializeAws_json1_1ValidateMatchmakingRuleSetCommandError = async ( throw await deserializeAws_json1_1UnsupportedRegionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11365,7 +11460,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -11391,6 +11486,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-gamesparks/src/protocols/Aws_restJson1.ts b/clients/client-gamesparks/src/protocols/Aws_restJson1.ts index 4025b67b51e19..b7da888018343 100644 --- a/clients/client-gamesparks/src/protocols/Aws_restJson1.ts +++ b/clients/client-gamesparks/src/protocols/Aws_restJson1.ts @@ -1382,8 +1382,7 @@ const deserializeAws_restJson1CreateGameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1405,10 +1404,12 @@ const deserializeAws_restJson1CreateGameCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1441,8 +1442,7 @@ const deserializeAws_restJson1CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1464,10 +1464,12 @@ const deserializeAws_restJson1CreateSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1500,8 +1502,7 @@ const deserializeAws_restJson1CreateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1523,10 +1524,12 @@ const deserializeAws_restJson1CreateStageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1555,8 +1558,7 @@ const deserializeAws_restJson1DeleteGameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1575,10 +1577,12 @@ const deserializeAws_restJson1DeleteGameCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1607,8 +1611,7 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1630,10 +1633,12 @@ const deserializeAws_restJson1DeleteStageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1670,8 +1675,7 @@ const deserializeAws_restJson1DisconnectPlayerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1690,10 +1694,12 @@ const deserializeAws_restJson1DisconnectPlayerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1726,8 +1732,7 @@ const deserializeAws_restJson1ExportSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1746,10 +1751,12 @@ const deserializeAws_restJson1ExportSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1782,8 +1789,7 @@ const deserializeAws_restJson1GetExtensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1802,10 +1808,12 @@ const deserializeAws_restJson1GetExtensionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1838,8 +1846,7 @@ const deserializeAws_restJson1GetExtensionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1858,10 +1865,12 @@ const deserializeAws_restJson1GetExtensionVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1894,8 +1903,7 @@ const deserializeAws_restJson1GetGameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1914,10 +1922,12 @@ const deserializeAws_restJson1GetGameCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1950,8 +1960,7 @@ const deserializeAws_restJson1GetGameConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -1970,10 +1979,12 @@ const deserializeAws_restJson1GetGameConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2006,8 +2017,7 @@ const deserializeAws_restJson1GetGeneratedCodeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2026,10 +2036,12 @@ const deserializeAws_restJson1GetGeneratedCodeJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2062,8 +2074,7 @@ const deserializeAws_restJson1GetPlayerConnectionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2082,10 +2093,12 @@ const deserializeAws_restJson1GetPlayerConnectionStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2118,8 +2131,7 @@ const deserializeAws_restJson1GetSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2138,10 +2150,12 @@ const deserializeAws_restJson1GetSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2174,8 +2188,7 @@ const deserializeAws_restJson1GetStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2194,10 +2207,12 @@ const deserializeAws_restJson1GetStageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2230,8 +2245,7 @@ const deserializeAws_restJson1GetStageDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2250,10 +2264,12 @@ const deserializeAws_restJson1GetStageDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2286,8 +2302,7 @@ const deserializeAws_restJson1ImportGameConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2309,10 +2324,12 @@ const deserializeAws_restJson1ImportGameConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2349,8 +2366,7 @@ const deserializeAws_restJson1ListExtensionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2366,10 +2382,12 @@ const deserializeAws_restJson1ListExtensionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2406,8 +2424,7 @@ const deserializeAws_restJson1ListExtensionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2426,10 +2443,12 @@ const deserializeAws_restJson1ListExtensionVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2466,8 +2485,7 @@ const deserializeAws_restJson1ListGamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2483,10 +2501,12 @@ const deserializeAws_restJson1ListGamesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2523,8 +2543,7 @@ const deserializeAws_restJson1ListGeneratedCodeJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2543,10 +2562,12 @@ const deserializeAws_restJson1ListGeneratedCodeJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2583,8 +2604,7 @@ const deserializeAws_restJson1ListSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2603,10 +2623,12 @@ const deserializeAws_restJson1ListSnapshotsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2643,8 +2665,7 @@ const deserializeAws_restJson1ListStageDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2663,10 +2684,12 @@ const deserializeAws_restJson1ListStageDeploymentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2703,8 +2726,7 @@ const deserializeAws_restJson1ListStagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2723,10 +2745,12 @@ const deserializeAws_restJson1ListStagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2759,8 +2783,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.gamesparks#InternalServerException": @@ -2773,10 +2796,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2809,8 +2834,7 @@ const deserializeAws_restJson1StartGeneratedCodeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2829,10 +2853,12 @@ const deserializeAws_restJson1StartGeneratedCodeJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2865,8 +2891,7 @@ const deserializeAws_restJson1StartStageDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -2888,10 +2913,12 @@ const deserializeAws_restJson1StartStageDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2920,8 +2947,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.gamesparks#InternalServerException": @@ -2934,10 +2960,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2966,8 +2994,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.gamesparks#InternalServerException": @@ -2980,10 +3007,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3016,8 +3045,7 @@ const deserializeAws_restJson1UpdateGameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -3036,10 +3064,12 @@ const deserializeAws_restJson1UpdateGameCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3072,8 +3102,7 @@ const deserializeAws_restJson1UpdateGameConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -3095,10 +3124,12 @@ const deserializeAws_restJson1UpdateGameConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3131,8 +3162,7 @@ const deserializeAws_restJson1UpdateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -3151,10 +3181,12 @@ const deserializeAws_restJson1UpdateSnapshotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3187,8 +3219,7 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.gamesparks#AccessDeniedException": @@ -3207,10 +3238,12 @@ const deserializeAws_restJson1UpdateStageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3799,7 +3832,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3825,6 +3858,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-glacier/src/protocols/Aws_restJson1.ts b/clients/client-glacier/src/protocols/Aws_restJson1.ts index c10a18d8b8dbd..57e66a25e4f79 100644 --- a/clients/client-glacier/src/protocols/Aws_restJson1.ts +++ b/clients/client-glacier/src/protocols/Aws_restJson1.ts @@ -1562,8 +1562,7 @@ const deserializeAws_restJson1AbortMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1579,10 +1578,12 @@ const deserializeAws_restJson1AbortMultipartUploadCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1611,8 +1612,7 @@ const deserializeAws_restJson1AbortVaultLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1628,10 +1628,12 @@ const deserializeAws_restJson1AbortVaultLockCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1660,8 +1662,7 @@ const deserializeAws_restJson1AddTagsToVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1680,10 +1681,12 @@ const deserializeAws_restJson1AddTagsToVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1724,8 +1727,7 @@ const deserializeAws_restJson1CompleteMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1741,10 +1743,12 @@ const deserializeAws_restJson1CompleteMultipartUploadCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1773,8 +1777,7 @@ const deserializeAws_restJson1CompleteVaultLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1790,10 +1793,12 @@ const deserializeAws_restJson1CompleteVaultLockCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1831,7 @@ const deserializeAws_restJson1CreateVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1843,10 +1847,12 @@ const deserializeAws_restJson1CreateVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1875,8 +1881,7 @@ const deserializeAws_restJson1DeleteArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1892,10 +1897,12 @@ const deserializeAws_restJson1DeleteArchiveCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1924,8 +1931,7 @@ const deserializeAws_restJson1DeleteVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1941,10 +1947,12 @@ const deserializeAws_restJson1DeleteVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1973,8 +1981,7 @@ const deserializeAws_restJson1DeleteVaultAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -1990,10 +1997,12 @@ const deserializeAws_restJson1DeleteVaultAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2022,8 +2031,7 @@ const deserializeAws_restJson1DeleteVaultNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2039,10 +2047,12 @@ const deserializeAws_restJson1DeleteVaultNotificationsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2158,8 +2168,7 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2175,10 +2184,12 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2231,8 +2242,7 @@ const deserializeAws_restJson1DescribeVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2248,10 +2258,12 @@ const deserializeAws_restJson1DescribeVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2284,8 +2296,7 @@ const deserializeAws_restJson1GetDataRetrievalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2298,10 +2309,12 @@ const deserializeAws_restJson1GetDataRetrievalPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2356,8 +2369,7 @@ const deserializeAws_restJson1GetJobOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2373,10 +2385,12 @@ const deserializeAws_restJson1GetJobOutputCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2407,8 +2421,7 @@ const deserializeAws_restJson1GetVaultAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2424,10 +2437,12 @@ const deserializeAws_restJson1GetVaultAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2472,8 +2487,7 @@ const deserializeAws_restJson1GetVaultLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2489,10 +2503,12 @@ const deserializeAws_restJson1GetVaultLockCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2523,8 +2539,7 @@ const deserializeAws_restJson1GetVaultNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2540,10 +2555,12 @@ const deserializeAws_restJson1GetVaultNotificationsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2584,8 +2601,7 @@ const deserializeAws_restJson1InitiateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapacityException": case "com.amazonaws.glacier#InsufficientCapacityException": @@ -2607,10 +2623,12 @@ const deserializeAws_restJson1InitiateJobCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2647,8 +2665,7 @@ const deserializeAws_restJson1InitiateMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2664,10 +2681,12 @@ const deserializeAws_restJson1InitiateMultipartUploadCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2700,8 +2719,7 @@ const deserializeAws_restJson1InitiateVaultLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2717,10 +2735,12 @@ const deserializeAws_restJson1InitiateVaultLockCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2757,8 +2777,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2774,10 +2793,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2814,8 +2835,7 @@ const deserializeAws_restJson1ListMultipartUploadsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2831,10 +2851,12 @@ const deserializeAws_restJson1ListMultipartUploadsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2891,8 +2913,7 @@ const deserializeAws_restJson1ListPartsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2908,10 +2929,12 @@ const deserializeAws_restJson1ListPartsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2947,8 +2970,7 @@ const deserializeAws_restJson1ListProvisionedCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -2961,10 +2983,12 @@ const deserializeAws_restJson1ListProvisionedCapacityCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2997,8 +3021,7 @@ const deserializeAws_restJson1ListTagsForVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3014,10 +3037,12 @@ const deserializeAws_restJson1ListTagsForVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3054,8 +3079,7 @@ const deserializeAws_restJson1ListVaultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3071,10 +3095,12 @@ const deserializeAws_restJson1ListVaultsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3107,8 +3133,7 @@ const deserializeAws_restJson1PurchaseProvisionedCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3124,10 +3149,12 @@ const deserializeAws_restJson1PurchaseProvisionedCapacityCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3156,8 +3183,7 @@ const deserializeAws_restJson1RemoveTagsFromVaultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3173,10 +3199,12 @@ const deserializeAws_restJson1RemoveTagsFromVaultCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3205,8 +3233,7 @@ const deserializeAws_restJson1SetDataRetrievalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3219,10 +3246,12 @@ const deserializeAws_restJson1SetDataRetrievalPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3251,8 +3280,7 @@ const deserializeAws_restJson1SetVaultAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3268,10 +3296,12 @@ const deserializeAws_restJson1SetVaultAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3300,8 +3330,7 @@ const deserializeAws_restJson1SetVaultNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3317,10 +3346,12 @@ const deserializeAws_restJson1SetVaultNotificationsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3361,8 +3392,7 @@ const deserializeAws_restJson1UploadArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3381,10 +3411,12 @@ const deserializeAws_restJson1UploadArchiveCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3417,8 +3449,7 @@ const deserializeAws_restJson1UploadMultipartPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.glacier#InvalidParameterValueException": @@ -3437,10 +3468,12 @@ const deserializeAws_restJson1UploadMultipartPartCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4275,7 +4308,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4301,6 +4334,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-global-accelerator/src/protocols/Aws_json1_1.ts b/clients/client-global-accelerator/src/protocols/Aws_json1_1.ts index d84266c66f921..79a165c30035f 100644 --- a/clients/client-global-accelerator/src/protocols/Aws_json1_1.ts +++ b/clients/client-global-accelerator/src/protocols/Aws_json1_1.ts @@ -929,8 +929,7 @@ const deserializeAws_json1_1AddCustomRoutingEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -955,10 +954,12 @@ const deserializeAws_json1_1AddCustomRoutingEndpointsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -990,8 +991,7 @@ const deserializeAws_json1_1AdvertiseByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -1010,10 +1010,12 @@ const deserializeAws_json1_1AdvertiseByoipCidrCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1042,8 +1044,7 @@ const deserializeAws_json1_1AllowCustomRoutingTrafficCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -1053,10 +1054,12 @@ const deserializeAws_json1_1AllowCustomRoutingTrafficCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1088,8 +1091,7 @@ const deserializeAws_json1_1CreateAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -1102,10 +1104,12 @@ const deserializeAws_json1_1CreateAcceleratorCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1137,8 +1141,7 @@ const deserializeAws_json1_1CreateCustomRoutingAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -1154,10 +1157,12 @@ const deserializeAws_json1_1CreateCustomRoutingAcceleratorCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1189,8 +1194,7 @@ const deserializeAws_json1_1CreateCustomRoutingEndpointGroupCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1218,10 +1222,12 @@ const deserializeAws_json1_1CreateCustomRoutingEndpointGroupCommandError = async throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1253,8 +1259,7 @@ const deserializeAws_json1_1CreateCustomRoutingListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1273,10 +1278,12 @@ const deserializeAws_json1_1CreateCustomRoutingListenerCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1308,8 +1315,7 @@ const deserializeAws_json1_1CreateEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1334,10 +1340,12 @@ const deserializeAws_json1_1CreateEndpointGroupCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1369,8 +1377,7 @@ const deserializeAws_json1_1CreateListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1389,10 +1396,12 @@ const deserializeAws_json1_1CreateListenerCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1421,8 +1430,7 @@ const deserializeAws_json1_1DeleteAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotDisabledException": case "com.amazonaws.globalaccelerator#AcceleratorNotDisabledException": @@ -1441,10 +1449,12 @@ const deserializeAws_json1_1DeleteAcceleratorCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1473,8 +1483,7 @@ const deserializeAws_json1_1DeleteCustomRoutingAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotDisabledException": case "com.amazonaws.globalaccelerator#AcceleratorNotDisabledException": @@ -1493,10 +1502,12 @@ const deserializeAws_json1_1DeleteCustomRoutingAcceleratorCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1525,8 +1536,7 @@ const deserializeAws_json1_1DeleteCustomRoutingEndpointGroupCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EndpointGroupNotFoundException": case "com.amazonaws.globalaccelerator#EndpointGroupNotFoundException": @@ -1539,10 +1549,12 @@ const deserializeAws_json1_1DeleteCustomRoutingEndpointGroupCommandError = async throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1571,8 +1583,7 @@ const deserializeAws_json1_1DeleteCustomRoutingListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociatedEndpointGroupFoundException": case "com.amazonaws.globalaccelerator#AssociatedEndpointGroupFoundException": @@ -1588,10 +1599,12 @@ const deserializeAws_json1_1DeleteCustomRoutingListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1620,8 +1633,7 @@ const deserializeAws_json1_1DeleteEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EndpointGroupNotFoundException": case "com.amazonaws.globalaccelerator#EndpointGroupNotFoundException": @@ -1634,10 +1646,12 @@ const deserializeAws_json1_1DeleteEndpointGroupCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1666,8 +1680,7 @@ const deserializeAws_json1_1DeleteListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociatedEndpointGroupFoundException": case "com.amazonaws.globalaccelerator#AssociatedEndpointGroupFoundException": @@ -1683,10 +1696,12 @@ const deserializeAws_json1_1DeleteListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1715,8 +1730,7 @@ const deserializeAws_json1_1DenyCustomRoutingTrafficCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -1726,10 +1740,12 @@ const deserializeAws_json1_1DenyCustomRoutingTrafficCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1761,8 +1777,7 @@ const deserializeAws_json1_1DeprovisionByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -1781,10 +1796,12 @@ const deserializeAws_json1_1DeprovisionByoipCidrCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1816,8 +1833,7 @@ const deserializeAws_json1_1DescribeAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1830,10 +1846,12 @@ const deserializeAws_json1_1DescribeAcceleratorCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1865,8 +1883,7 @@ const deserializeAws_json1_1DescribeAcceleratorAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1879,10 +1896,12 @@ const deserializeAws_json1_1DescribeAcceleratorAttributesCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1914,8 +1933,7 @@ const deserializeAws_json1_1DescribeCustomRoutingAcceleratorCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1928,10 +1946,12 @@ const deserializeAws_json1_1DescribeCustomRoutingAcceleratorCommandError = async throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1963,8 +1983,7 @@ const deserializeAws_json1_1DescribeCustomRoutingAcceleratorAttributesCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -1977,10 +1996,12 @@ const deserializeAws_json1_1DescribeCustomRoutingAcceleratorAttributesCommandErr throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2012,8 +2033,7 @@ const deserializeAws_json1_1DescribeCustomRoutingEndpointGroupCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EndpointGroupNotFoundException": case "com.amazonaws.globalaccelerator#EndpointGroupNotFoundException": @@ -2026,10 +2046,12 @@ const deserializeAws_json1_1DescribeCustomRoutingEndpointGroupCommandError = asy throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2061,8 +2083,7 @@ const deserializeAws_json1_1DescribeCustomRoutingListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2075,10 +2096,12 @@ const deserializeAws_json1_1DescribeCustomRoutingListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2110,8 +2133,7 @@ const deserializeAws_json1_1DescribeEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EndpointGroupNotFoundException": case "com.amazonaws.globalaccelerator#EndpointGroupNotFoundException": @@ -2124,10 +2146,12 @@ const deserializeAws_json1_1DescribeEndpointGroupCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2159,8 +2183,7 @@ const deserializeAws_json1_1DescribeListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2173,10 +2196,12 @@ const deserializeAws_json1_1DescribeListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2208,8 +2233,7 @@ const deserializeAws_json1_1ListAcceleratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2222,10 +2246,12 @@ const deserializeAws_json1_1ListAcceleratorsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2257,8 +2283,7 @@ const deserializeAws_json1_1ListByoipCidrsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -2274,10 +2299,12 @@ const deserializeAws_json1_1ListByoipCidrsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2309,8 +2336,7 @@ const deserializeAws_json1_1ListCustomRoutingAcceleratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2323,10 +2349,12 @@ const deserializeAws_json1_1ListCustomRoutingAcceleratorsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2358,8 +2386,7 @@ const deserializeAws_json1_1ListCustomRoutingEndpointGroupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2375,10 +2402,12 @@ const deserializeAws_json1_1ListCustomRoutingEndpointGroupsCommandError = async throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2410,8 +2439,7 @@ const deserializeAws_json1_1ListCustomRoutingListenersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2427,10 +2455,12 @@ const deserializeAws_json1_1ListCustomRoutingListenersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2462,8 +2492,7 @@ const deserializeAws_json1_1ListCustomRoutingPortMappingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2482,10 +2511,12 @@ const deserializeAws_json1_1ListCustomRoutingPortMappingsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2517,8 +2548,7 @@ const deserializeAws_json1_1ListCustomRoutingPortMappingsByDestinationCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EndpointNotFoundException": case "com.amazonaws.globalaccelerator#EndpointNotFoundException": @@ -2534,10 +2564,12 @@ const deserializeAws_json1_1ListCustomRoutingPortMappingsByDestinationCommandErr throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2569,8 +2601,7 @@ const deserializeAws_json1_1ListEndpointGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -2586,10 +2617,12 @@ const deserializeAws_json1_1ListEndpointGroupsCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2621,8 +2654,7 @@ const deserializeAws_json1_1ListListenersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2638,10 +2670,12 @@ const deserializeAws_json1_1ListListenersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2673,8 +2707,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2687,10 +2720,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2722,8 +2757,7 @@ const deserializeAws_json1_1ProvisionByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -2742,10 +2776,12 @@ const deserializeAws_json1_1ProvisionByoipCidrCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2774,8 +2810,7 @@ const deserializeAws_json1_1RemoveCustomRoutingEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -2797,10 +2832,12 @@ const deserializeAws_json1_1RemoveCustomRoutingEndpointsCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2832,8 +2869,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2846,10 +2882,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2881,8 +2919,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2895,10 +2932,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2930,8 +2969,7 @@ const deserializeAws_json1_1UpdateAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2944,10 +2982,12 @@ const deserializeAws_json1_1UpdateAcceleratorCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2979,8 +3019,7 @@ const deserializeAws_json1_1UpdateAcceleratorAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -2996,10 +3035,12 @@ const deserializeAws_json1_1UpdateAcceleratorAttributesCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3031,8 +3072,7 @@ const deserializeAws_json1_1UpdateCustomRoutingAcceleratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -3045,10 +3085,12 @@ const deserializeAws_json1_1UpdateCustomRoutingAcceleratorCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3080,8 +3122,7 @@ const deserializeAws_json1_1UpdateCustomRoutingAcceleratorAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AcceleratorNotFoundException": case "com.amazonaws.globalaccelerator#AcceleratorNotFoundException": @@ -3097,10 +3138,12 @@ const deserializeAws_json1_1UpdateCustomRoutingAcceleratorAttributesCommandError throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3132,8 +3175,7 @@ const deserializeAws_json1_1UpdateCustomRoutingListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -3152,10 +3194,12 @@ const deserializeAws_json1_1UpdateCustomRoutingListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3187,8 +3231,7 @@ const deserializeAws_json1_1UpdateEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -3207,10 +3250,12 @@ const deserializeAws_json1_1UpdateEndpointGroupCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3242,8 +3287,7 @@ const deserializeAws_json1_1UpdateListenerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.globalaccelerator#InternalServiceErrorException": @@ -3262,10 +3306,12 @@ const deserializeAws_json1_1UpdateListenerCommandError = async ( throw await deserializeAws_json1_1ListenerNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3297,8 +3343,7 @@ const deserializeAws_json1_1WithdrawByoipCidrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.globalaccelerator#AccessDeniedException": @@ -3317,10 +3362,12 @@ const deserializeAws_json1_1WithdrawByoipCidrCommandError = async ( throw await deserializeAws_json1_1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5512,7 +5559,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5538,6 +5585,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-glue/src/protocols/Aws_json1_1.ts b/clients/client-glue/src/protocols/Aws_json1_1.ts index 3e1fe05e35465..0e8e4a2d85c68 100644 --- a/clients/client-glue/src/protocols/Aws_json1_1.ts +++ b/clients/client-glue/src/protocols/Aws_json1_1.ts @@ -3438,8 +3438,7 @@ const deserializeAws_json1_1BatchCreatePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -3464,10 +3463,12 @@ const deserializeAws_json1_1BatchCreatePartitionCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3499,8 +3500,7 @@ const deserializeAws_json1_1BatchDeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -3510,10 +3510,12 @@ const deserializeAws_json1_1BatchDeleteConnectionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3545,8 +3547,7 @@ const deserializeAws_json1_1BatchDeletePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -3562,10 +3563,12 @@ const deserializeAws_json1_1BatchDeletePartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3597,8 +3600,7 @@ const deserializeAws_json1_1BatchDeleteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -3620,10 +3622,12 @@ const deserializeAws_json1_1BatchDeleteTableCommandError = async ( throw await deserializeAws_json1_1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3655,8 +3659,7 @@ const deserializeAws_json1_1BatchDeleteTableVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -3672,10 +3675,12 @@ const deserializeAws_json1_1BatchDeleteTableVersionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3707,8 +3712,7 @@ const deserializeAws_json1_1BatchGetBlueprintsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -3721,10 +3725,12 @@ const deserializeAws_json1_1BatchGetBlueprintsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3756,8 +3762,7 @@ const deserializeAws_json1_1BatchGetCrawlersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.glue#InvalidInputException": @@ -3767,10 +3772,12 @@ const deserializeAws_json1_1BatchGetCrawlersCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3802,8 +3809,7 @@ const deserializeAws_json1_1BatchGetCustomEntityTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -3816,10 +3822,12 @@ const deserializeAws_json1_1BatchGetCustomEntityTypesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3851,8 +3859,7 @@ const deserializeAws_json1_1BatchGetDevEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -3868,10 +3875,12 @@ const deserializeAws_json1_1BatchGetDevEndpointsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3903,8 +3912,7 @@ const deserializeAws_json1_1BatchGetJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -3917,10 +3925,12 @@ const deserializeAws_json1_1BatchGetJobsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3952,8 +3962,7 @@ const deserializeAws_json1_1BatchGetPartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -3975,10 +3984,12 @@ const deserializeAws_json1_1BatchGetPartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4010,8 +4021,7 @@ const deserializeAws_json1_1BatchGetTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -4024,10 +4034,12 @@ const deserializeAws_json1_1BatchGetTriggersCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4059,8 +4071,7 @@ const deserializeAws_json1_1BatchGetWorkflowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -4073,10 +4084,12 @@ const deserializeAws_json1_1BatchGetWorkflowsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4108,8 +4121,7 @@ const deserializeAws_json1_1BatchStopJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -4122,10 +4134,12 @@ const deserializeAws_json1_1BatchStopJobRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4157,8 +4171,7 @@ const deserializeAws_json1_1BatchUpdatePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -4177,10 +4190,12 @@ const deserializeAws_json1_1BatchUpdatePartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4212,8 +4227,7 @@ const deserializeAws_json1_1CancelMLTaskRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -4229,10 +4243,12 @@ const deserializeAws_json1_1CancelMLTaskRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4264,8 +4280,7 @@ const deserializeAws_json1_1CancelStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -4287,10 +4302,12 @@ const deserializeAws_json1_1CancelStatementCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4322,8 +4339,7 @@ const deserializeAws_json1_1CheckSchemaVersionValidityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -4336,10 +4352,12 @@ const deserializeAws_json1_1CheckSchemaVersionValidityCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4371,8 +4389,7 @@ const deserializeAws_json1_1CreateBlueprintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4391,10 +4408,12 @@ const deserializeAws_json1_1CreateBlueprintCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4426,8 +4445,7 @@ const deserializeAws_json1_1CreateClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4440,10 +4458,12 @@ const deserializeAws_json1_1CreateClassifierCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4475,8 +4495,7 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4495,10 +4514,12 @@ const deserializeAws_json1_1CreateConnectionCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4530,8 +4551,7 @@ const deserializeAws_json1_1CreateCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4547,10 +4567,12 @@ const deserializeAws_json1_1CreateCrawlerCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4582,8 +4604,7 @@ const deserializeAws_json1_1CreateCustomEntityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -4608,10 +4629,12 @@ const deserializeAws_json1_1CreateCustomEntityTypeCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4643,8 +4666,7 @@ const deserializeAws_json1_1CreateDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4669,10 +4691,12 @@ const deserializeAws_json1_1CreateDatabaseCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4704,8 +4728,7 @@ const deserializeAws_json1_1CreateDevEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -4733,10 +4756,12 @@ const deserializeAws_json1_1CreateDevEndpointCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4768,8 +4793,7 @@ const deserializeAws_json1_1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4794,10 +4818,12 @@ const deserializeAws_json1_1CreateJobCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4829,8 +4855,7 @@ const deserializeAws_json1_1CreateMLTransformCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -4855,10 +4880,12 @@ const deserializeAws_json1_1CreateMLTransformCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4890,8 +4917,7 @@ const deserializeAws_json1_1CreatePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4916,10 +4942,12 @@ const deserializeAws_json1_1CreatePartitionCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4951,8 +4979,7 @@ const deserializeAws_json1_1CreatePartitionIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -4977,10 +5004,12 @@ const deserializeAws_json1_1CreatePartitionIndexCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5012,8 +5041,7 @@ const deserializeAws_json1_1CreateRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -5035,10 +5063,12 @@ const deserializeAws_json1_1CreateRegistryCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5070,8 +5100,7 @@ const deserializeAws_json1_1CreateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -5096,10 +5125,12 @@ const deserializeAws_json1_1CreateSchemaCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5131,8 +5162,7 @@ const deserializeAws_json1_1CreateScriptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -5145,10 +5175,12 @@ const deserializeAws_json1_1CreateScriptCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5180,8 +5212,7 @@ const deserializeAws_json1_1CreateSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -5200,10 +5231,12 @@ const deserializeAws_json1_1CreateSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5235,8 +5268,7 @@ const deserializeAws_json1_1CreateSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -5264,10 +5296,12 @@ const deserializeAws_json1_1CreateSessionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5299,8 +5333,7 @@ const deserializeAws_json1_1CreateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -5331,10 +5364,12 @@ const deserializeAws_json1_1CreateTableCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5366,8 +5401,7 @@ const deserializeAws_json1_1CreateTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -5395,10 +5429,12 @@ const deserializeAws_json1_1CreateTriggerCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5430,8 +5466,7 @@ const deserializeAws_json1_1CreateUserDefinedFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -5456,10 +5491,12 @@ const deserializeAws_json1_1CreateUserDefinedFunctionCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5491,8 +5528,7 @@ const deserializeAws_json1_1CreateWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -5514,10 +5550,12 @@ const deserializeAws_json1_1CreateWorkflowCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5549,8 +5587,7 @@ const deserializeAws_json1_1DeleteBlueprintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -5563,10 +5600,12 @@ const deserializeAws_json1_1DeleteBlueprintCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5598,8 +5637,7 @@ const deserializeAws_json1_1DeleteClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -5609,10 +5647,12 @@ const deserializeAws_json1_1DeleteClassifierCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5644,8 +5684,7 @@ const deserializeAws_json1_1DeleteColumnStatisticsForPartitionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -5664,10 +5703,12 @@ const deserializeAws_json1_1DeleteColumnStatisticsForPartitionCommandError = asy throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5699,8 +5740,7 @@ const deserializeAws_json1_1DeleteColumnStatisticsForTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -5719,10 +5759,12 @@ const deserializeAws_json1_1DeleteColumnStatisticsForTableCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5754,8 +5796,7 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -5765,10 +5806,12 @@ const deserializeAws_json1_1DeleteConnectionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5800,8 +5843,7 @@ const deserializeAws_json1_1DeleteCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CrawlerRunningException": case "com.amazonaws.glue#CrawlerRunningException": @@ -5817,10 +5859,12 @@ const deserializeAws_json1_1DeleteCrawlerCommandError = async ( throw await deserializeAws_json1_1SchedulerTransitioningExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5852,8 +5896,7 @@ const deserializeAws_json1_1DeleteCustomEntityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -5872,10 +5915,12 @@ const deserializeAws_json1_1DeleteCustomEntityTypeCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5907,8 +5952,7 @@ const deserializeAws_json1_1DeleteDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -5927,10 +5971,12 @@ const deserializeAws_json1_1DeleteDatabaseCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5962,8 +6008,7 @@ const deserializeAws_json1_1DeleteDevEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -5979,10 +6024,12 @@ const deserializeAws_json1_1DeleteDevEndpointCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6014,8 +6061,7 @@ const deserializeAws_json1_1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -6028,10 +6074,12 @@ const deserializeAws_json1_1DeleteJobCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6063,8 +6111,7 @@ const deserializeAws_json1_1DeleteMLTransformCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6080,10 +6127,12 @@ const deserializeAws_json1_1DeleteMLTransformCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6115,8 +6164,7 @@ const deserializeAws_json1_1DeletePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6132,10 +6180,12 @@ const deserializeAws_json1_1DeletePartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6167,8 +6217,7 @@ const deserializeAws_json1_1DeletePartitionIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.glue#ConflictException": @@ -6190,10 +6239,12 @@ const deserializeAws_json1_1DeletePartitionIndexCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6225,8 +6276,7 @@ const deserializeAws_json1_1DeleteRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -6242,10 +6292,12 @@ const deserializeAws_json1_1DeleteRegistryCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6277,8 +6329,7 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionCheckFailureException": case "com.amazonaws.glue#ConditionCheckFailureException": @@ -6297,10 +6348,12 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6332,8 +6385,7 @@ const deserializeAws_json1_1DeleteSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -6349,10 +6401,12 @@ const deserializeAws_json1_1DeleteSchemaCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6384,8 +6438,7 @@ const deserializeAws_json1_1DeleteSchemaVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -6401,10 +6454,12 @@ const deserializeAws_json1_1DeleteSchemaVersionsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6436,8 +6491,7 @@ const deserializeAws_json1_1DeleteSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6453,10 +6507,12 @@ const deserializeAws_json1_1DeleteSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6488,8 +6544,7 @@ const deserializeAws_json1_1DeleteSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -6511,10 +6566,12 @@ const deserializeAws_json1_1DeleteSessionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6546,8 +6603,7 @@ const deserializeAws_json1_1DeleteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -6569,10 +6625,12 @@ const deserializeAws_json1_1DeleteTableCommandError = async ( throw await deserializeAws_json1_1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6604,8 +6662,7 @@ const deserializeAws_json1_1DeleteTableVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6621,10 +6678,12 @@ const deserializeAws_json1_1DeleteTableVersionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6656,8 +6715,7 @@ const deserializeAws_json1_1DeleteTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -6673,10 +6731,12 @@ const deserializeAws_json1_1DeleteTriggerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6708,8 +6768,7 @@ const deserializeAws_json1_1DeleteUserDefinedFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6725,10 +6784,12 @@ const deserializeAws_json1_1DeleteUserDefinedFunctionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6760,8 +6821,7 @@ const deserializeAws_json1_1DeleteWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -6777,10 +6837,12 @@ const deserializeAws_json1_1DeleteWorkflowCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6812,8 +6874,7 @@ const deserializeAws_json1_1GetBlueprintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6829,10 +6890,12 @@ const deserializeAws_json1_1GetBlueprintCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6864,8 +6927,7 @@ const deserializeAws_json1_1GetBlueprintRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6878,10 +6940,12 @@ const deserializeAws_json1_1GetBlueprintRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6913,8 +6977,7 @@ const deserializeAws_json1_1GetBlueprintRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -6930,10 +6993,12 @@ const deserializeAws_json1_1GetBlueprintRunsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6965,8 +7030,7 @@ const deserializeAws_json1_1GetCatalogImportStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -6976,10 +7040,12 @@ const deserializeAws_json1_1GetCatalogImportStatusCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7011,8 +7077,7 @@ const deserializeAws_json1_1GetClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7022,10 +7087,12 @@ const deserializeAws_json1_1GetClassifierCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7057,18 +7124,19 @@ const deserializeAws_json1_1GetClassifiersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationTimeoutException": case "com.amazonaws.glue#OperationTimeoutException": throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7100,8 +7168,7 @@ const deserializeAws_json1_1GetColumnStatisticsForPartitionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7120,10 +7187,12 @@ const deserializeAws_json1_1GetColumnStatisticsForPartitionCommandError = async throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7155,8 +7224,7 @@ const deserializeAws_json1_1GetColumnStatisticsForTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7175,10 +7243,12 @@ const deserializeAws_json1_1GetColumnStatisticsForTableCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7210,8 +7280,7 @@ const deserializeAws_json1_1GetConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7227,10 +7296,12 @@ const deserializeAws_json1_1GetConnectionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7262,8 +7333,7 @@ const deserializeAws_json1_1GetConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7279,10 +7349,12 @@ const deserializeAws_json1_1GetConnectionsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7314,8 +7386,7 @@ const deserializeAws_json1_1GetCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7325,10 +7396,12 @@ const deserializeAws_json1_1GetCrawlerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7360,18 +7433,19 @@ const deserializeAws_json1_1GetCrawlerMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationTimeoutException": case "com.amazonaws.glue#OperationTimeoutException": throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7403,18 +7477,19 @@ const deserializeAws_json1_1GetCrawlersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationTimeoutException": case "com.amazonaws.glue#OperationTimeoutException": throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7446,8 +7521,7 @@ const deserializeAws_json1_1GetCustomEntityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -7466,10 +7540,12 @@ const deserializeAws_json1_1GetCustomEntityTypeCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7501,8 +7577,7 @@ const deserializeAws_json1_1GetDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7521,10 +7596,12 @@ const deserializeAws_json1_1GetDatabaseCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7556,8 +7633,7 @@ const deserializeAws_json1_1GetDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlueEncryptionException": case "com.amazonaws.glue#GlueEncryptionException": @@ -7573,10 +7649,12 @@ const deserializeAws_json1_1GetDatabasesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7608,8 +7686,7 @@ const deserializeAws_json1_1GetDataCatalogEncryptionSettingsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -7622,10 +7699,12 @@ const deserializeAws_json1_1GetDataCatalogEncryptionSettingsCommandError = async throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7657,8 +7736,7 @@ const deserializeAws_json1_1GetDataflowGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -7671,10 +7749,12 @@ const deserializeAws_json1_1GetDataflowGraphCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7706,8 +7786,7 @@ const deserializeAws_json1_1GetDevEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7723,10 +7802,12 @@ const deserializeAws_json1_1GetDevEndpointCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7758,8 +7839,7 @@ const deserializeAws_json1_1GetDevEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7775,10 +7855,12 @@ const deserializeAws_json1_1GetDevEndpointsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7810,8 +7892,7 @@ const deserializeAws_json1_1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7827,10 +7908,12 @@ const deserializeAws_json1_1GetJobCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7862,8 +7945,7 @@ const deserializeAws_json1_1GetJobBookmarkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7882,10 +7964,12 @@ const deserializeAws_json1_1GetJobBookmarkCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7917,8 +8001,7 @@ const deserializeAws_json1_1GetJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7934,10 +8017,12 @@ const deserializeAws_json1_1GetJobRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7969,8 +8054,7 @@ const deserializeAws_json1_1GetJobRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -7986,10 +8070,12 @@ const deserializeAws_json1_1GetJobRunsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8021,8 +8107,7 @@ const deserializeAws_json1_1GetJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8038,10 +8123,12 @@ const deserializeAws_json1_1GetJobsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8073,8 +8160,7 @@ const deserializeAws_json1_1GetMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8090,10 +8176,12 @@ const deserializeAws_json1_1GetMappingCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8125,8 +8213,7 @@ const deserializeAws_json1_1GetMLTaskRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8142,10 +8229,12 @@ const deserializeAws_json1_1GetMLTaskRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8177,8 +8266,7 @@ const deserializeAws_json1_1GetMLTaskRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8194,10 +8282,12 @@ const deserializeAws_json1_1GetMLTaskRunsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8229,8 +8319,7 @@ const deserializeAws_json1_1GetMLTransformCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8246,10 +8335,12 @@ const deserializeAws_json1_1GetMLTransformCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8281,8 +8372,7 @@ const deserializeAws_json1_1GetMLTransformsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8298,10 +8388,12 @@ const deserializeAws_json1_1GetMLTransformsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8333,8 +8425,7 @@ const deserializeAws_json1_1GetPartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8353,10 +8444,12 @@ const deserializeAws_json1_1GetPartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8388,8 +8481,7 @@ const deserializeAws_json1_1GetPartitionIndexesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.glue#ConflictException": @@ -8408,10 +8500,12 @@ const deserializeAws_json1_1GetPartitionIndexesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8443,8 +8537,7 @@ const deserializeAws_json1_1GetPartitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8469,10 +8562,12 @@ const deserializeAws_json1_1GetPartitionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8504,8 +8599,7 @@ const deserializeAws_json1_1GetPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -8518,10 +8612,12 @@ const deserializeAws_json1_1GetPlanCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8553,8 +8649,7 @@ const deserializeAws_json1_1GetRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -8570,10 +8665,12 @@ const deserializeAws_json1_1GetRegistryCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8605,8 +8702,7 @@ const deserializeAws_json1_1GetResourcePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlueEncryptionException": case "com.amazonaws.glue#GlueEncryptionException": @@ -8622,10 +8718,12 @@ const deserializeAws_json1_1GetResourcePoliciesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8657,8 +8755,7 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8674,10 +8771,12 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8709,8 +8808,7 @@ const deserializeAws_json1_1GetSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -8726,10 +8824,12 @@ const deserializeAws_json1_1GetSchemaCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8761,8 +8861,7 @@ const deserializeAws_json1_1GetSchemaByDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -8778,10 +8877,12 @@ const deserializeAws_json1_1GetSchemaByDefinitionCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8813,8 +8914,7 @@ const deserializeAws_json1_1GetSchemaVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -8830,10 +8930,12 @@ const deserializeAws_json1_1GetSchemaVersionCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8865,8 +8967,7 @@ const deserializeAws_json1_1GetSchemaVersionsDiffCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -8882,10 +8983,12 @@ const deserializeAws_json1_1GetSchemaVersionsDiffCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8917,8 +9020,7 @@ const deserializeAws_json1_1GetSecurityConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8934,10 +9036,12 @@ const deserializeAws_json1_1GetSecurityConfigurationCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8969,8 +9073,7 @@ const deserializeAws_json1_1GetSecurityConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -8986,10 +9089,12 @@ const deserializeAws_json1_1GetSecurityConfigurationsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9021,8 +9126,7 @@ const deserializeAws_json1_1GetSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -9041,10 +9145,12 @@ const deserializeAws_json1_1GetSessionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9076,8 +9182,7 @@ const deserializeAws_json1_1GetStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -9099,10 +9204,12 @@ const deserializeAws_json1_1GetStatementCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9134,8 +9241,7 @@ const deserializeAws_json1_1GetTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9157,10 +9263,12 @@ const deserializeAws_json1_1GetTableCommandError = async ( throw await deserializeAws_json1_1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9192,8 +9300,7 @@ const deserializeAws_json1_1GetTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9212,10 +9319,12 @@ const deserializeAws_json1_1GetTablesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9247,8 +9356,7 @@ const deserializeAws_json1_1GetTableVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9267,10 +9375,12 @@ const deserializeAws_json1_1GetTableVersionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9302,8 +9412,7 @@ const deserializeAws_json1_1GetTableVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9322,10 +9431,12 @@ const deserializeAws_json1_1GetTableVersionsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9357,8 +9468,7 @@ const deserializeAws_json1_1GetTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9374,10 +9484,12 @@ const deserializeAws_json1_1GetTagsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9409,8 +9521,7 @@ const deserializeAws_json1_1GetTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9426,10 +9537,12 @@ const deserializeAws_json1_1GetTriggerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9461,8 +9574,7 @@ const deserializeAws_json1_1GetTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9478,10 +9590,12 @@ const deserializeAws_json1_1GetTriggersCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9513,8 +9627,7 @@ const deserializeAws_json1_1GetUnfilteredPartitionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9536,10 +9649,12 @@ const deserializeAws_json1_1GetUnfilteredPartitionMetadataCommandError = async ( throw await deserializeAws_json1_1PermissionTypeMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9571,8 +9686,7 @@ const deserializeAws_json1_1GetUnfilteredPartitionsMetadataCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9594,10 +9708,12 @@ const deserializeAws_json1_1GetUnfilteredPartitionsMetadataCommandError = async throw await deserializeAws_json1_1PermissionTypeMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9629,8 +9745,7 @@ const deserializeAws_json1_1GetUnfilteredTableMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9652,10 +9767,12 @@ const deserializeAws_json1_1GetUnfilteredTableMetadataCommandError = async ( throw await deserializeAws_json1_1PermissionTypeMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9687,8 +9804,7 @@ const deserializeAws_json1_1GetUserDefinedFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9707,10 +9823,12 @@ const deserializeAws_json1_1GetUserDefinedFunctionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9742,8 +9860,7 @@ const deserializeAws_json1_1GetUserDefinedFunctionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9762,10 +9879,12 @@ const deserializeAws_json1_1GetUserDefinedFunctionsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9797,8 +9916,7 @@ const deserializeAws_json1_1GetWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9814,10 +9932,12 @@ const deserializeAws_json1_1GetWorkflowCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9849,8 +9969,7 @@ const deserializeAws_json1_1GetWorkflowRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9866,10 +9985,12 @@ const deserializeAws_json1_1GetWorkflowRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9901,8 +10022,7 @@ const deserializeAws_json1_1GetWorkflowRunPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9918,10 +10038,12 @@ const deserializeAws_json1_1GetWorkflowRunPropertiesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9953,8 +10075,7 @@ const deserializeAws_json1_1GetWorkflowRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -9970,10 +10091,12 @@ const deserializeAws_json1_1GetWorkflowRunsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10005,8 +10128,7 @@ const deserializeAws_json1_1ImportCatalogToGlueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -10016,10 +10138,12 @@ const deserializeAws_json1_1ImportCatalogToGlueCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10051,8 +10175,7 @@ const deserializeAws_json1_1ListBlueprintsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -10065,10 +10188,12 @@ const deserializeAws_json1_1ListBlueprintsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10100,18 +10225,19 @@ const deserializeAws_json1_1ListCrawlersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationTimeoutException": case "com.amazonaws.glue#OperationTimeoutException": throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10143,8 +10269,7 @@ const deserializeAws_json1_1ListCrawlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -10157,10 +10282,12 @@ const deserializeAws_json1_1ListCrawlsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10192,8 +10319,7 @@ const deserializeAws_json1_1ListCustomEntityTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -10206,10 +10332,12 @@ const deserializeAws_json1_1ListCustomEntityTypesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10241,8 +10369,7 @@ const deserializeAws_json1_1ListDevEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -10258,10 +10385,12 @@ const deserializeAws_json1_1ListDevEndpointsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10293,8 +10422,7 @@ const deserializeAws_json1_1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -10310,10 +10438,12 @@ const deserializeAws_json1_1ListJobsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10345,8 +10475,7 @@ const deserializeAws_json1_1ListMLTransformsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -10362,10 +10491,12 @@ const deserializeAws_json1_1ListMLTransformsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10397,8 +10528,7 @@ const deserializeAws_json1_1ListRegistriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10411,10 +10541,12 @@ const deserializeAws_json1_1ListRegistriesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10446,8 +10578,7 @@ const deserializeAws_json1_1ListSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10463,10 +10594,12 @@ const deserializeAws_json1_1ListSchemasCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10498,8 +10631,7 @@ const deserializeAws_json1_1ListSchemaVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10515,10 +10647,12 @@ const deserializeAws_json1_1ListSchemaVersionsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10550,8 +10684,7 @@ const deserializeAws_json1_1ListSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10567,10 +10700,12 @@ const deserializeAws_json1_1ListSessionsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10602,8 +10737,7 @@ const deserializeAws_json1_1ListStatementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10625,10 +10759,12 @@ const deserializeAws_json1_1ListStatementsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10660,8 +10796,7 @@ const deserializeAws_json1_1ListTriggersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -10677,10 +10812,12 @@ const deserializeAws_json1_1ListTriggersCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10712,8 +10849,7 @@ const deserializeAws_json1_1ListWorkflowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -10726,10 +10862,12 @@ const deserializeAws_json1_1ListWorkflowsCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10761,8 +10899,7 @@ const deserializeAws_json1_1PutDataCatalogEncryptionSettingsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -10775,10 +10912,12 @@ const deserializeAws_json1_1PutDataCatalogEncryptionSettingsCommandError = async throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10810,8 +10949,7 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConditionCheckFailureException": case "com.amazonaws.glue#ConditionCheckFailureException": @@ -10830,10 +10968,12 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10865,8 +11005,7 @@ const deserializeAws_json1_1PutSchemaVersionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10885,10 +11024,12 @@ const deserializeAws_json1_1PutSchemaVersionMetadataCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10920,8 +11061,7 @@ const deserializeAws_json1_1PutWorkflowRunPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.glue#AlreadyExistsException": @@ -10946,10 +11086,12 @@ const deserializeAws_json1_1PutWorkflowRunPropertiesCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10981,8 +11123,7 @@ const deserializeAws_json1_1QuerySchemaVersionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -10995,10 +11136,12 @@ const deserializeAws_json1_1QuerySchemaVersionMetadataCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11030,8 +11173,7 @@ const deserializeAws_json1_1RegisterSchemaVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -11053,10 +11195,12 @@ const deserializeAws_json1_1RegisterSchemaVersionCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11088,8 +11232,7 @@ const deserializeAws_json1_1RemoveSchemaVersionMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -11102,10 +11245,12 @@ const deserializeAws_json1_1RemoveSchemaVersionMetadataCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11137,8 +11282,7 @@ const deserializeAws_json1_1ResetJobBookmarkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11154,10 +11298,12 @@ const deserializeAws_json1_1ResetJobBookmarkCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11189,8 +11335,7 @@ const deserializeAws_json1_1ResumeWorkflowRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11212,10 +11357,12 @@ const deserializeAws_json1_1ResumeWorkflowRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11247,8 +11394,7 @@ const deserializeAws_json1_1RunStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -11276,10 +11422,12 @@ const deserializeAws_json1_1RunStatementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11311,8 +11459,7 @@ const deserializeAws_json1_1SearchTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.glue#InternalServiceException": @@ -11325,10 +11472,12 @@ const deserializeAws_json1_1SearchTablesCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11360,8 +11509,7 @@ const deserializeAws_json1_1StartBlueprintRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11383,10 +11531,12 @@ const deserializeAws_json1_1StartBlueprintRunCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11418,8 +11568,7 @@ const deserializeAws_json1_1StartCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CrawlerRunningException": case "com.amazonaws.glue#CrawlerRunningException": @@ -11432,10 +11581,12 @@ const deserializeAws_json1_1StartCrawlerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11467,8 +11618,7 @@ const deserializeAws_json1_1StartCrawlerScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11487,10 +11637,12 @@ const deserializeAws_json1_1StartCrawlerScheduleCommandError = async ( throw await deserializeAws_json1_1SchedulerTransitioningExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11522,8 +11674,7 @@ const deserializeAws_json1_1StartExportLabelsTaskRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11539,10 +11690,12 @@ const deserializeAws_json1_1StartExportLabelsTaskRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11574,8 +11727,7 @@ const deserializeAws_json1_1StartImportLabelsTaskRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11594,10 +11746,12 @@ const deserializeAws_json1_1StartImportLabelsTaskRunCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11629,8 +11783,7 @@ const deserializeAws_json1_1StartJobRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11652,10 +11805,12 @@ const deserializeAws_json1_1StartJobRunCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11687,8 +11842,7 @@ const deserializeAws_json1_1StartMLEvaluationTaskRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11710,10 +11864,12 @@ const deserializeAws_json1_1StartMLEvaluationTaskRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11745,8 +11901,7 @@ const deserializeAws_json1_1StartMLLabelingSetGenerationTaskRunCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11765,10 +11920,12 @@ const deserializeAws_json1_1StartMLLabelingSetGenerationTaskRunCommandError = as throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11800,8 +11957,7 @@ const deserializeAws_json1_1StartTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11823,10 +11979,12 @@ const deserializeAws_json1_1StartTriggerCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11858,8 +12016,7 @@ const deserializeAws_json1_1StartWorkflowRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentRunsExceededException": case "com.amazonaws.glue#ConcurrentRunsExceededException": @@ -11881,10 +12038,12 @@ const deserializeAws_json1_1StartWorkflowRunCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11916,8 +12075,7 @@ const deserializeAws_json1_1StopCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CrawlerNotRunningException": case "com.amazonaws.glue#CrawlerNotRunningException": @@ -11933,10 +12091,12 @@ const deserializeAws_json1_1StopCrawlerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11968,8 +12128,7 @@ const deserializeAws_json1_1StopCrawlerScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -11985,10 +12144,12 @@ const deserializeAws_json1_1StopCrawlerScheduleCommandError = async ( throw await deserializeAws_json1_1SchedulerTransitioningExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12020,8 +12181,7 @@ const deserializeAws_json1_1StopSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -12043,10 +12203,12 @@ const deserializeAws_json1_1StopSessionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12078,8 +12240,7 @@ const deserializeAws_json1_1StopTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -12098,10 +12259,12 @@ const deserializeAws_json1_1StopTriggerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12133,8 +12296,7 @@ const deserializeAws_json1_1StopWorkflowRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12153,10 +12315,12 @@ const deserializeAws_json1_1StopWorkflowRunCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12188,8 +12352,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12205,10 +12368,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12240,8 +12405,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12257,10 +12421,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12292,8 +12458,7 @@ const deserializeAws_json1_1UpdateBlueprintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -12315,10 +12480,12 @@ const deserializeAws_json1_1UpdateBlueprintCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12350,8 +12517,7 @@ const deserializeAws_json1_1UpdateClassifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12367,10 +12533,12 @@ const deserializeAws_json1_1UpdateClassifierCommandError = async ( throw await deserializeAws_json1_1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12402,8 +12570,7 @@ const deserializeAws_json1_1UpdateColumnStatisticsForPartitionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12422,10 +12589,12 @@ const deserializeAws_json1_1UpdateColumnStatisticsForPartitionCommandError = asy throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12457,8 +12626,7 @@ const deserializeAws_json1_1UpdateColumnStatisticsForTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12477,10 +12645,12 @@ const deserializeAws_json1_1UpdateColumnStatisticsForTableCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12512,8 +12682,7 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12529,10 +12698,12 @@ const deserializeAws_json1_1UpdateConnectionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12564,8 +12735,7 @@ const deserializeAws_json1_1UpdateCrawlerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CrawlerRunningException": case "com.amazonaws.glue#CrawlerRunningException": @@ -12584,10 +12754,12 @@ const deserializeAws_json1_1UpdateCrawlerCommandError = async ( throw await deserializeAws_json1_1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12619,8 +12791,7 @@ const deserializeAws_json1_1UpdateCrawlerScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12639,10 +12810,12 @@ const deserializeAws_json1_1UpdateCrawlerScheduleCommandError = async ( throw await deserializeAws_json1_1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12674,8 +12847,7 @@ const deserializeAws_json1_1UpdateDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -12697,10 +12869,12 @@ const deserializeAws_json1_1UpdateDatabaseCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12732,8 +12906,7 @@ const deserializeAws_json1_1UpdateDevEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12752,10 +12925,12 @@ const deserializeAws_json1_1UpdateDevEndpointCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12787,8 +12962,7 @@ const deserializeAws_json1_1UpdateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -12807,10 +12981,12 @@ const deserializeAws_json1_1UpdateJobCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12842,8 +13018,7 @@ const deserializeAws_json1_1UpdateMLTransformCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -12862,10 +13037,12 @@ const deserializeAws_json1_1UpdateMLTransformCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12897,8 +13074,7 @@ const deserializeAws_json1_1UpdatePartitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -12917,10 +13093,12 @@ const deserializeAws_json1_1UpdatePartitionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12952,8 +13130,7 @@ const deserializeAws_json1_1UpdateRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -12972,10 +13149,12 @@ const deserializeAws_json1_1UpdateRegistryCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13007,8 +13186,7 @@ const deserializeAws_json1_1UpdateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.glue#AccessDeniedException": @@ -13027,10 +13205,12 @@ const deserializeAws_json1_1UpdateSchemaCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13062,8 +13242,7 @@ const deserializeAws_json1_1UpdateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -13091,10 +13270,12 @@ const deserializeAws_json1_1UpdateTableCommandError = async ( throw await deserializeAws_json1_1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13126,8 +13307,7 @@ const deserializeAws_json1_1UpdateTriggerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -13146,10 +13326,12 @@ const deserializeAws_json1_1UpdateTriggerCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13181,8 +13363,7 @@ const deserializeAws_json1_1UpdateUserDefinedFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.glue#EntityNotFoundException": @@ -13201,10 +13382,12 @@ const deserializeAws_json1_1UpdateUserDefinedFunctionCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13236,8 +13419,7 @@ const deserializeAws_json1_1UpdateWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.glue#ConcurrentModificationException": @@ -13256,10 +13438,12 @@ const deserializeAws_json1_1UpdateWorkflowCommandError = async ( throw await deserializeAws_json1_1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -26146,7 +26330,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -26172,6 +26356,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-grafana/src/protocols/Aws_restJson1.ts b/clients/client-grafana/src/protocols/Aws_restJson1.ts index 62268bbfcd77b..e5b45c9f32054 100644 --- a/clients/client-grafana/src/protocols/Aws_restJson1.ts +++ b/clients/client-grafana/src/protocols/Aws_restJson1.ts @@ -704,8 +704,7 @@ const deserializeAws_restJson1AssociateLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -724,10 +723,12 @@ const deserializeAws_restJson1AssociateLicenseCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -760,8 +761,7 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -783,10 +783,12 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -827,8 +829,7 @@ const deserializeAws_restJson1CreateWorkspaceApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -853,10 +854,12 @@ const deserializeAws_restJson1CreateWorkspaceApiKeyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -889,8 +892,7 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -912,10 +914,12 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -952,8 +956,7 @@ const deserializeAws_restJson1DeleteWorkspaceApiKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -975,10 +978,12 @@ const deserializeAws_restJson1DeleteWorkspaceApiKeyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1011,8 +1016,7 @@ const deserializeAws_restJson1DescribeWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1031,10 +1035,12 @@ const deserializeAws_restJson1DescribeWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1067,8 +1073,7 @@ const deserializeAws_restJson1DescribeWorkspaceAuthenticationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1087,10 +1092,12 @@ const deserializeAws_restJson1DescribeWorkspaceAuthenticationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1123,8 +1130,7 @@ const deserializeAws_restJson1DisassociateLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1143,10 +1149,12 @@ const deserializeAws_restJson1DisassociateLicenseCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1183,8 +1191,7 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1203,10 +1210,12 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1239,8 +1248,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1259,10 +1267,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1299,8 +1309,7 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1313,10 +1322,12 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1345,8 +1356,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1365,10 +1375,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1397,8 +1409,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1417,10 +1428,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,8 +1466,7 @@ const deserializeAws_restJson1UpdatePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1473,10 +1485,12 @@ const deserializeAws_restJson1UpdatePermissionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1509,8 +1523,7 @@ const deserializeAws_restJson1UpdateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1532,10 +1545,12 @@ const deserializeAws_restJson1UpdateWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1568,8 +1583,7 @@ const deserializeAws_restJson1UpdateWorkspaceAuthenticationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.grafana#AccessDeniedException": @@ -1591,10 +1605,12 @@ const deserializeAws_restJson1UpdateWorkspaceAuthenticationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2355,7 +2371,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2381,6 +2397,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-greengrass/src/protocols/Aws_restJson1.ts b/clients/client-greengrass/src/protocols/Aws_restJson1.ts index 811b175e876c0..5a8b6127836c4 100644 --- a/clients/client-greengrass/src/protocols/Aws_restJson1.ts +++ b/clients/client-greengrass/src/protocols/Aws_restJson1.ts @@ -3447,8 +3447,7 @@ const deserializeAws_restJson1AssociateRoleToGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -3458,10 +3457,12 @@ const deserializeAws_restJson1AssociateRoleToGroupCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3494,8 +3495,7 @@ const deserializeAws_restJson1AssociateServiceRoleToAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -3505,10 +3505,12 @@ const deserializeAws_restJson1AssociateServiceRoleToAccountCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3565,18 +3567,19 @@ const deserializeAws_restJson1CreateConnectorDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3621,18 +3624,19 @@ const deserializeAws_restJson1CreateConnectorDefinitionVersionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3689,18 +3693,19 @@ const deserializeAws_restJson1CreateCoreDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3745,18 +3750,19 @@ const deserializeAws_restJson1CreateCoreDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3793,18 +3799,19 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3861,18 +3868,19 @@ const deserializeAws_restJson1CreateDeviceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3917,18 +3925,19 @@ const deserializeAws_restJson1CreateDeviceDefinitionVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3985,18 +3994,19 @@ const deserializeAws_restJson1CreateFunctionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4041,18 +4051,19 @@ const deserializeAws_restJson1CreateFunctionDefinitionVersionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4109,18 +4120,19 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4153,8 +4165,7 @@ const deserializeAws_restJson1CreateGroupCertificateAuthorityCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -4164,10 +4175,12 @@ const deserializeAws_restJson1CreateGroupCertificateAuthorityCommandError = asyn throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4212,18 +4225,19 @@ const deserializeAws_restJson1CreateGroupVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4280,18 +4294,19 @@ const deserializeAws_restJson1CreateLoggerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4336,18 +4351,19 @@ const deserializeAws_restJson1CreateLoggerDefinitionVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4404,18 +4420,19 @@ const deserializeAws_restJson1CreateResourceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4460,18 +4477,19 @@ const deserializeAws_restJson1CreateResourceDefinitionVersionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4512,8 +4530,7 @@ const deserializeAws_restJson1CreateSoftwareUpdateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -4523,10 +4540,12 @@ const deserializeAws_restJson1CreateSoftwareUpdateJobCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4583,18 +4602,19 @@ const deserializeAws_restJson1CreateSubscriptionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4639,18 +4659,19 @@ const deserializeAws_restJson1CreateSubscriptionDefinitionVersionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4679,18 +4700,19 @@ const deserializeAws_restJson1DeleteConnectorDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4719,18 +4741,19 @@ const deserializeAws_restJson1DeleteCoreDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4759,18 +4782,19 @@ const deserializeAws_restJson1DeleteDeviceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4799,18 +4823,19 @@ const deserializeAws_restJson1DeleteFunctionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4839,18 +4864,19 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4879,18 +4905,19 @@ const deserializeAws_restJson1DeleteLoggerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4919,18 +4946,19 @@ const deserializeAws_restJson1DeleteResourceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4959,18 +4987,19 @@ const deserializeAws_restJson1DeleteSubscriptionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5003,8 +5032,7 @@ const deserializeAws_restJson1DisassociateRoleFromGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -5014,10 +5042,12 @@ const deserializeAws_restJson1DisassociateRoleFromGroupCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5050,18 +5080,19 @@ const deserializeAws_restJson1DisassociateServiceRoleFromAccountCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.greengrass#InternalServerErrorException": throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5098,8 +5129,7 @@ const deserializeAws_restJson1GetAssociatedRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -5109,10 +5139,12 @@ const deserializeAws_restJson1GetAssociatedRoleCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5165,18 +5197,19 @@ const deserializeAws_restJson1GetBulkDeploymentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5213,8 +5246,7 @@ const deserializeAws_restJson1GetConnectivityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -5224,10 +5256,12 @@ const deserializeAws_restJson1GetConnectivityInfoCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5288,18 +5322,19 @@ const deserializeAws_restJson1GetConnectorDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5352,18 +5387,19 @@ const deserializeAws_restJson1GetConnectorDefinitionVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5424,18 +5460,19 @@ const deserializeAws_restJson1GetCoreDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5488,18 +5525,19 @@ const deserializeAws_restJson1GetCoreDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5548,18 +5586,19 @@ const deserializeAws_restJson1GetDeploymentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5620,18 +5659,19 @@ const deserializeAws_restJson1GetDeviceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5684,18 +5724,19 @@ const deserializeAws_restJson1GetDeviceDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5756,18 +5797,19 @@ const deserializeAws_restJson1GetFunctionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5820,18 +5862,19 @@ const deserializeAws_restJson1GetFunctionDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5892,18 +5935,19 @@ const deserializeAws_restJson1GetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5944,8 +5988,7 @@ const deserializeAws_restJson1GetGroupCertificateAuthorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -5955,10 +5998,12 @@ const deserializeAws_restJson1GetGroupCertificateAuthorityCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6002,8 +6047,7 @@ const deserializeAws_restJson1GetGroupCertificateConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -6013,10 +6057,12 @@ const deserializeAws_restJson1GetGroupCertificateConfigurationCommandError = asy throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6065,18 +6111,19 @@ const deserializeAws_restJson1GetGroupVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6137,18 +6184,19 @@ const deserializeAws_restJson1GetLoggerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6197,18 +6245,19 @@ const deserializeAws_restJson1GetLoggerDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6269,18 +6318,19 @@ const deserializeAws_restJson1GetResourceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6329,18 +6379,19 @@ const deserializeAws_restJson1GetResourceDefinitionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6377,18 +6428,19 @@ const deserializeAws_restJson1GetServiceRoleForAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.greengrass#InternalServerErrorException": throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6449,18 +6501,19 @@ const deserializeAws_restJson1GetSubscriptionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6513,18 +6566,19 @@ const deserializeAws_restJson1GetSubscriptionDefinitionVersionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6557,8 +6611,7 @@ const deserializeAws_restJson1GetThingRuntimeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -6568,10 +6621,12 @@ const deserializeAws_restJson1GetThingRuntimeConfigurationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6608,18 +6663,19 @@ const deserializeAws_restJson1ListBulkDeploymentDetailedReportsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6656,18 +6712,19 @@ const deserializeAws_restJson1ListBulkDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6704,15 +6761,16 @@ const deserializeAws_restJson1ListConnectorDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6749,18 +6807,19 @@ const deserializeAws_restJson1ListConnectorDefinitionVersionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6797,15 +6856,16 @@ const deserializeAws_restJson1ListCoreDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6842,18 +6902,19 @@ const deserializeAws_restJson1ListCoreDefinitionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6890,18 +6951,19 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6938,15 +7000,16 @@ const deserializeAws_restJson1ListDeviceDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6983,18 +7046,19 @@ const deserializeAws_restJson1ListDeviceDefinitionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7031,15 +7095,16 @@ const deserializeAws_restJson1ListFunctionDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7076,18 +7141,19 @@ const deserializeAws_restJson1ListFunctionDefinitionVersionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7123,8 +7189,7 @@ const deserializeAws_restJson1ListGroupCertificateAuthoritiesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -7134,10 +7199,12 @@ const deserializeAws_restJson1ListGroupCertificateAuthoritiesCommandError = asyn throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7174,15 +7241,16 @@ const deserializeAws_restJson1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7219,18 +7287,19 @@ const deserializeAws_restJson1ListGroupVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7267,15 +7336,16 @@ const deserializeAws_restJson1ListLoggerDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7312,18 +7382,19 @@ const deserializeAws_restJson1ListLoggerDefinitionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7360,15 +7431,16 @@ const deserializeAws_restJson1ListResourceDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7405,18 +7477,19 @@ const deserializeAws_restJson1ListResourceDefinitionVersionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7453,15 +7526,16 @@ const deserializeAws_restJson1ListSubscriptionDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7498,18 +7572,19 @@ const deserializeAws_restJson1ListSubscriptionDefinitionVersionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7542,18 +7617,19 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7590,18 +7666,19 @@ const deserializeAws_restJson1ResetDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7638,18 +7715,19 @@ const deserializeAws_restJson1StartBulkDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7678,18 +7756,19 @@ const deserializeAws_restJson1StopBulkDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7718,18 +7797,19 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7758,18 +7838,19 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7806,8 +7887,7 @@ const deserializeAws_restJson1UpdateConnectivityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -7817,10 +7897,12 @@ const deserializeAws_restJson1UpdateConnectivityInfoCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7849,18 +7931,19 @@ const deserializeAws_restJson1UpdateConnectorDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7889,18 +7972,19 @@ const deserializeAws_restJson1UpdateCoreDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7929,18 +8013,19 @@ const deserializeAws_restJson1UpdateDeviceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7969,18 +8054,19 @@ const deserializeAws_restJson1UpdateFunctionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8009,18 +8095,19 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8064,8 +8151,7 @@ const deserializeAws_restJson1UpdateGroupCertificateConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -8075,10 +8161,12 @@ const deserializeAws_restJson1UpdateGroupCertificateConfigurationCommandError = throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8107,18 +8195,19 @@ const deserializeAws_restJson1UpdateLoggerDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8147,18 +8236,19 @@ const deserializeAws_restJson1UpdateResourceDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8187,18 +8277,19 @@ const deserializeAws_restJson1UpdateSubscriptionDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8227,8 +8318,7 @@ const deserializeAws_restJson1UpdateThingRuntimeConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.greengrass#BadRequestException": @@ -8238,10 +8328,12 @@ const deserializeAws_restJson1UpdateThingRuntimeConfigurationCommandError = asyn throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9613,7 +9705,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9639,6 +9731,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-greengrassv2/src/protocols/Aws_restJson1.ts b/clients/client-greengrassv2/src/protocols/Aws_restJson1.ts index d0c0300eed1b1..c0294f30f18a0 100644 --- a/clients/client-greengrassv2/src/protocols/Aws_restJson1.ts +++ b/clients/client-greengrassv2/src/protocols/Aws_restJson1.ts @@ -1089,8 +1089,7 @@ const deserializeAws_restJson1AssociateServiceRoleToAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -1100,10 +1099,12 @@ const deserializeAws_restJson1AssociateServiceRoleToAccountCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1139,8 +1140,7 @@ const deserializeAws_restJson1BatchAssociateClientDeviceWithCoreDeviceCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1159,10 +1159,12 @@ const deserializeAws_restJson1BatchAssociateClientDeviceWithCoreDeviceCommandErr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1198,8 +1200,7 @@ const deserializeAws_restJson1BatchDisassociateClientDeviceFromCoreDeviceCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1218,10 +1219,12 @@ const deserializeAws_restJson1BatchDisassociateClientDeviceFromCoreDeviceCommand throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,8 +1257,7 @@ const deserializeAws_restJson1CancelDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1277,10 +1279,12 @@ const deserializeAws_restJson1CancelDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1329,8 +1333,7 @@ const deserializeAws_restJson1CreateComponentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1355,10 +1358,12 @@ const deserializeAws_restJson1CreateComponentVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1399,8 +1404,7 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1425,10 +1429,12 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1457,8 +1463,7 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1480,10 +1485,12 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1512,8 +1519,7 @@ const deserializeAws_restJson1DeleteCoreDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1535,10 +1541,12 @@ const deserializeAws_restJson1DeleteCoreDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1567,8 +1575,7 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1590,10 +1597,12 @@ const deserializeAws_restJson1DeleteDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1658,8 +1667,7 @@ const deserializeAws_restJson1DescribeComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1678,10 +1686,12 @@ const deserializeAws_restJson1DescribeComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1714,18 +1724,19 @@ const deserializeAws_restJson1DisassociateServiceRoleFromAccountCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1766,8 +1777,7 @@ const deserializeAws_restJson1GetComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1786,10 +1796,12 @@ const deserializeAws_restJson1GetComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1822,8 +1834,7 @@ const deserializeAws_restJson1GetComponentVersionArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1842,10 +1853,12 @@ const deserializeAws_restJson1GetComponentVersionArtifactCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1882,8 +1895,7 @@ const deserializeAws_restJson1GetConnectivityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -1893,10 +1905,12 @@ const deserializeAws_restJson1GetConnectivityInfoCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1955,8 +1969,7 @@ const deserializeAws_restJson1GetCoreDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -1975,10 +1988,12 @@ const deserializeAws_restJson1GetCoreDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2062,8 +2077,7 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2082,10 +2096,12 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2122,18 +2138,19 @@ const deserializeAws_restJson1GetServiceRoleForAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2173,8 +2190,7 @@ const deserializeAws_restJson1ListClientDevicesAssociatedWithCoreDeviceCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2193,10 +2209,12 @@ const deserializeAws_restJson1ListClientDevicesAssociatedWithCoreDeviceCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2233,8 +2251,7 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2253,10 +2270,12 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2293,8 +2312,7 @@ const deserializeAws_restJson1ListComponentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2313,10 +2331,12 @@ const deserializeAws_restJson1ListComponentVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2353,8 +2373,7 @@ const deserializeAws_restJson1ListCoreDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2370,10 +2389,12 @@ const deserializeAws_restJson1ListCoreDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2410,8 +2431,7 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2427,10 +2447,12 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2470,8 +2492,7 @@ const deserializeAws_restJson1ListEffectiveDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2490,10 +2511,12 @@ const deserializeAws_restJson1ListEffectiveDeploymentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2530,8 +2553,7 @@ const deserializeAws_restJson1ListInstalledComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2550,10 +2572,12 @@ const deserializeAws_restJson1ListInstalledComponentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2586,8 +2610,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -2600,10 +2623,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2639,8 +2664,7 @@ const deserializeAws_restJson1ResolveComponentCandidatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.greengrassv2#AccessDeniedException": @@ -2662,10 +2686,12 @@ const deserializeAws_restJson1ResolveComponentCandidatesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2694,8 +2720,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -2708,10 +2733,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2740,8 +2767,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -2754,10 +2780,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2794,8 +2822,7 @@ const deserializeAws_restJson1UpdateConnectivityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.greengrassv2#InternalServerException": @@ -2805,10 +2832,12 @@ const deserializeAws_restJson1UpdateConnectivityInfoCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4196,7 +4225,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4222,6 +4251,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-groundstation/src/protocols/Aws_restJson1.ts b/clients/client-groundstation/src/protocols/Aws_restJson1.ts index 5bf347821736b..05c4143822ca5 100644 --- a/clients/client-groundstation/src/protocols/Aws_restJson1.ts +++ b/clients/client-groundstation/src/protocols/Aws_restJson1.ts @@ -924,8 +924,7 @@ const deserializeAws_restJson1CancelContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -938,10 +937,12 @@ const deserializeAws_restJson1CancelContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -982,8 +983,7 @@ const deserializeAws_restJson1CreateConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -999,10 +999,12 @@ const deserializeAws_restJson1CreateConfigCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1035,8 +1037,7 @@ const deserializeAws_restJson1CreateDataflowEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1049,10 +1050,12 @@ const deserializeAws_restJson1CreateDataflowEndpointGroupCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1085,8 +1088,7 @@ const deserializeAws_restJson1CreateMissionProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1099,10 +1101,12 @@ const deserializeAws_restJson1CreateMissionProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1143,8 +1147,7 @@ const deserializeAws_restJson1DeleteConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1157,10 +1160,12 @@ const deserializeAws_restJson1DeleteConfigCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1193,8 +1198,7 @@ const deserializeAws_restJson1DeleteDataflowEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1207,10 +1211,12 @@ const deserializeAws_restJson1DeleteDataflowEndpointGroupCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1249,7 @@ const deserializeAws_restJson1DeleteMissionProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1257,10 +1262,12 @@ const deserializeAws_restJson1DeleteMissionProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1345,8 +1352,7 @@ const deserializeAws_restJson1DescribeContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1359,10 +1365,12 @@ const deserializeAws_restJson1DescribeContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1415,8 +1423,7 @@ const deserializeAws_restJson1GetConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1429,10 +1436,12 @@ const deserializeAws_restJson1GetConfigCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1477,8 +1486,7 @@ const deserializeAws_restJson1GetDataflowEndpointGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1491,10 +1499,12 @@ const deserializeAws_restJson1GetDataflowEndpointGroupCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1543,8 +1553,7 @@ const deserializeAws_restJson1GetMinuteUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1557,10 +1566,12 @@ const deserializeAws_restJson1GetMinuteUsageCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1629,8 +1640,7 @@ const deserializeAws_restJson1GetMissionProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1643,10 +1653,12 @@ const deserializeAws_restJson1GetMissionProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1691,8 +1703,7 @@ const deserializeAws_restJson1GetSatelliteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1705,10 +1716,12 @@ const deserializeAws_restJson1GetSatelliteCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1745,8 +1758,7 @@ const deserializeAws_restJson1ListConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1759,10 +1771,12 @@ const deserializeAws_restJson1ListConfigsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1799,8 +1813,7 @@ const deserializeAws_restJson1ListContactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1813,10 +1826,12 @@ const deserializeAws_restJson1ListContactsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1856,8 +1871,7 @@ const deserializeAws_restJson1ListDataflowEndpointGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1870,10 +1884,12 @@ const deserializeAws_restJson1ListDataflowEndpointGroupsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1910,8 +1926,7 @@ const deserializeAws_restJson1ListGroundStationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1924,10 +1939,12 @@ const deserializeAws_restJson1ListGroundStationsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1964,8 +1981,7 @@ const deserializeAws_restJson1ListMissionProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -1978,10 +1994,12 @@ const deserializeAws_restJson1ListMissionProfilesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2018,8 +2036,7 @@ const deserializeAws_restJson1ListSatellitesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2032,10 +2049,12 @@ const deserializeAws_restJson1ListSatellitesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2068,8 +2087,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2082,10 +2100,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2118,8 +2138,7 @@ const deserializeAws_restJson1ReserveContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2132,10 +2151,12 @@ const deserializeAws_restJson1ReserveContactCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2164,8 +2185,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2178,10 +2198,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2210,8 +2232,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2224,10 +2245,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2268,8 +2291,7 @@ const deserializeAws_restJson1UpdateConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2282,10 +2304,12 @@ const deserializeAws_restJson1UpdateConfigCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2318,8 +2342,7 @@ const deserializeAws_restJson1UpdateMissionProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyException": case "com.amazonaws.groundstation#DependencyException": @@ -2332,10 +2355,12 @@ const deserializeAws_restJson1UpdateMissionProfileCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3278,7 +3303,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3304,6 +3329,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-guardduty/src/protocols/Aws_restJson1.ts b/clients/client-guardduty/src/protocols/Aws_restJson1.ts index 7b0da450b41c6..2f6c1cabcf008 100644 --- a/clients/client-guardduty/src/protocols/Aws_restJson1.ts +++ b/clients/client-guardduty/src/protocols/Aws_restJson1.ts @@ -2459,8 +2459,7 @@ const deserializeAws_restJson1AcceptAdministratorInvitationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2470,10 +2469,12 @@ const deserializeAws_restJson1AcceptAdministratorInvitationCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2502,8 +2503,7 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2513,10 +2513,12 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2545,8 +2547,7 @@ const deserializeAws_restJson1ArchiveFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2556,10 +2557,12 @@ const deserializeAws_restJson1ArchiveFindingsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2592,8 +2595,7 @@ const deserializeAws_restJson1CreateDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2603,10 +2605,12 @@ const deserializeAws_restJson1CreateDetectorCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2639,8 +2643,7 @@ const deserializeAws_restJson1CreateFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2650,10 +2653,12 @@ const deserializeAws_restJson1CreateFilterCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2686,8 +2691,7 @@ const deserializeAws_restJson1CreateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2697,10 +2701,12 @@ const deserializeAws_restJson1CreateIPSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2733,8 +2739,7 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2744,10 +2749,12 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2780,8 +2787,7 @@ const deserializeAws_restJson1CreatePublishingDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2791,10 +2797,12 @@ const deserializeAws_restJson1CreatePublishingDestinationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2823,8 +2831,7 @@ const deserializeAws_restJson1CreateSampleFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2834,10 +2841,12 @@ const deserializeAws_restJson1CreateSampleFindingsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2870,8 +2879,7 @@ const deserializeAws_restJson1CreateThreatIntelSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2881,10 +2889,12 @@ const deserializeAws_restJson1CreateThreatIntelSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2917,8 +2927,7 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2928,10 +2937,12 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2960,8 +2971,7 @@ const deserializeAws_restJson1DeleteDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -2971,10 +2981,12 @@ const deserializeAws_restJson1DeleteDetectorCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3003,8 +3015,7 @@ const deserializeAws_restJson1DeleteFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3014,10 +3025,12 @@ const deserializeAws_restJson1DeleteFilterCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3050,8 +3063,7 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3061,10 +3073,12 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3093,8 +3107,7 @@ const deserializeAws_restJson1DeleteIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3104,10 +3117,12 @@ const deserializeAws_restJson1DeleteIPSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3140,8 +3155,7 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3151,10 +3165,12 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3183,8 +3199,7 @@ const deserializeAws_restJson1DeletePublishingDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3194,10 +3209,12 @@ const deserializeAws_restJson1DeletePublishingDestinationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3226,8 +3243,7 @@ const deserializeAws_restJson1DeleteThreatIntelSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3237,10 +3253,12 @@ const deserializeAws_restJson1DeleteThreatIntelSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3284,8 +3302,7 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3295,10 +3312,12 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3347,8 +3366,7 @@ const deserializeAws_restJson1DescribePublishingDestinationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3358,10 +3376,12 @@ const deserializeAws_restJson1DescribePublishingDestinationCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3390,8 +3410,7 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3401,10 +3420,12 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3433,8 +3454,7 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3444,10 +3464,12 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3476,8 +3498,7 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3487,10 +3508,12 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3523,8 +3546,7 @@ const deserializeAws_restJson1DisassociateMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3534,10 +3556,12 @@ const deserializeAws_restJson1DisassociateMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3566,8 +3590,7 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3577,10 +3600,12 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3613,8 +3638,7 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3624,10 +3648,12 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3684,8 +3710,7 @@ const deserializeAws_restJson1GetDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3695,10 +3720,12 @@ const deserializeAws_restJson1GetDetectorCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3751,8 +3778,7 @@ const deserializeAws_restJson1GetFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3762,10 +3788,12 @@ const deserializeAws_restJson1GetFilterCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3798,8 +3826,7 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3809,10 +3836,12 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3845,8 +3874,7 @@ const deserializeAws_restJson1GetFindingsStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3856,10 +3884,12 @@ const deserializeAws_restJson1GetFindingsStatisticsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3892,8 +3922,7 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3903,10 +3932,12 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3955,8 +3986,7 @@ const deserializeAws_restJson1GetIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -3966,10 +3996,12 @@ const deserializeAws_restJson1GetIPSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4002,8 +4034,7 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4013,10 +4044,12 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4056,8 +4089,7 @@ const deserializeAws_restJson1GetMemberDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4067,10 +4099,12 @@ const deserializeAws_restJson1GetMemberDetectorsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4107,8 +4141,7 @@ const deserializeAws_restJson1GetMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4118,10 +4151,12 @@ const deserializeAws_restJson1GetMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4158,8 +4193,7 @@ const deserializeAws_restJson1GetRemainingFreeTrialDaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4169,10 +4203,12 @@ const deserializeAws_restJson1GetRemainingFreeTrialDaysCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4221,8 +4257,7 @@ const deserializeAws_restJson1GetThreatIntelSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4232,10 +4267,12 @@ const deserializeAws_restJson1GetThreatIntelSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4272,8 +4309,7 @@ const deserializeAws_restJson1GetUsageStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4283,10 +4319,12 @@ const deserializeAws_restJson1GetUsageStatisticsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4319,8 +4357,7 @@ const deserializeAws_restJson1InviteMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4330,10 +4367,12 @@ const deserializeAws_restJson1InviteMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4370,8 +4409,7 @@ const deserializeAws_restJson1ListDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4381,10 +4419,12 @@ const deserializeAws_restJson1ListDetectorsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4421,8 +4461,7 @@ const deserializeAws_restJson1ListFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4432,10 +4471,12 @@ const deserializeAws_restJson1ListFiltersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4472,8 +4513,7 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4483,10 +4523,12 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4523,8 +4565,7 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4534,10 +4575,12 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4574,8 +4617,7 @@ const deserializeAws_restJson1ListIPSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4585,10 +4627,12 @@ const deserializeAws_restJson1ListIPSetsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4625,8 +4669,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4636,10 +4679,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4676,8 +4721,7 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4687,10 +4731,12 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4727,8 +4773,7 @@ const deserializeAws_restJson1ListPublishingDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4738,10 +4783,12 @@ const deserializeAws_restJson1ListPublishingDestinationsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4774,8 +4821,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4785,10 +4831,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4825,8 +4873,7 @@ const deserializeAws_restJson1ListThreatIntelSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4836,10 +4883,12 @@ const deserializeAws_restJson1ListThreatIntelSetsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4872,8 +4921,7 @@ const deserializeAws_restJson1StartMonitoringMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4883,10 +4931,12 @@ const deserializeAws_restJson1StartMonitoringMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4919,8 +4969,7 @@ const deserializeAws_restJson1StopMonitoringMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4930,10 +4979,12 @@ const deserializeAws_restJson1StopMonitoringMembersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4962,8 +5013,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -4973,10 +5023,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5005,8 +5057,7 @@ const deserializeAws_restJson1UnarchiveFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5016,10 +5067,12 @@ const deserializeAws_restJson1UnarchiveFindingsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5048,8 +5101,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5059,10 +5111,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5091,8 +5145,7 @@ const deserializeAws_restJson1UpdateDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5102,10 +5155,12 @@ const deserializeAws_restJson1UpdateDetectorCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5138,8 +5193,7 @@ const deserializeAws_restJson1UpdateFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5149,10 +5203,12 @@ const deserializeAws_restJson1UpdateFilterCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5181,8 +5237,7 @@ const deserializeAws_restJson1UpdateFindingsFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5192,10 +5247,12 @@ const deserializeAws_restJson1UpdateFindingsFeedbackCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5224,8 +5281,7 @@ const deserializeAws_restJson1UpdateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5235,10 +5291,12 @@ const deserializeAws_restJson1UpdateIPSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5271,8 +5329,7 @@ const deserializeAws_restJson1UpdateMemberDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5282,10 +5339,12 @@ const deserializeAws_restJson1UpdateMemberDetectorsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5314,8 +5373,7 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5325,10 +5383,12 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5357,8 +5417,7 @@ const deserializeAws_restJson1UpdatePublishingDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5368,10 +5427,12 @@ const deserializeAws_restJson1UpdatePublishingDestinationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5400,8 +5461,7 @@ const deserializeAws_restJson1UpdateThreatIntelSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.guardduty#BadRequestException": @@ -5411,10 +5471,12 @@ const deserializeAws_restJson1UpdateThreatIntelSetCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7302,7 +7364,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7328,6 +7390,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-health/src/protocols/Aws_json1_1.ts b/clients/client-health/src/protocols/Aws_json1_1.ts index 379d8c5b03b61..625961a3567a6 100644 --- a/clients/client-health/src/protocols/Aws_json1_1.ts +++ b/clients/client-health/src/protocols/Aws_json1_1.ts @@ -302,18 +302,19 @@ const deserializeAws_json1_1DescribeAffectedAccountsForOrganizationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": throw await deserializeAws_json1_1InvalidPaginationTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -345,8 +346,7 @@ const deserializeAws_json1_1DescribeAffectedEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": @@ -356,10 +356,12 @@ const deserializeAws_json1_1DescribeAffectedEntitiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -391,8 +393,7 @@ const deserializeAws_json1_1DescribeAffectedEntitiesForOrganizationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": @@ -402,10 +403,12 @@ const deserializeAws_json1_1DescribeAffectedEntitiesForOrganizationCommandError throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -437,15 +440,16 @@ const deserializeAws_json1_1DescribeEntityAggregatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -477,18 +481,19 @@ const deserializeAws_json1_1DescribeEventAggregatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": throw await deserializeAws_json1_1InvalidPaginationTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -520,18 +525,19 @@ const deserializeAws_json1_1DescribeEventDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UnsupportedLocale": case "com.amazonaws.health#UnsupportedLocale": throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -563,18 +569,19 @@ const deserializeAws_json1_1DescribeEventDetailsForOrganizationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UnsupportedLocale": case "com.amazonaws.health#UnsupportedLocale": throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -606,8 +613,7 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": @@ -617,10 +623,12 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -652,8 +660,7 @@ const deserializeAws_json1_1DescribeEventsForOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": @@ -663,10 +670,12 @@ const deserializeAws_json1_1DescribeEventsForOrganizationCommandError = async ( throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -698,8 +707,7 @@ const deserializeAws_json1_1DescribeEventTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPaginationToken": case "com.amazonaws.health#InvalidPaginationToken": @@ -709,10 +717,12 @@ const deserializeAws_json1_1DescribeEventTypesCommandError = async ( throw await deserializeAws_json1_1UnsupportedLocaleResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -744,15 +754,16 @@ const deserializeAws_json1_1DescribeHealthServiceStatusForOrganizationCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -781,18 +792,19 @@ const deserializeAws_json1_1DisableHealthServiceAccessForOrganizationCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.health#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -821,18 +833,19 @@ const deserializeAws_json1_1EnableHealthServiceAccessForOrganizationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.health#ConcurrentModificationException": throw await deserializeAws_json1_1ConcurrentModificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1936,7 +1949,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1962,6 +1975,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-healthlake/src/protocols/Aws_json1_0.ts b/clients/client-healthlake/src/protocols/Aws_json1_0.ts index 47736f83eda78..4124bd897f96e 100644 --- a/clients/client-healthlake/src/protocols/Aws_json1_0.ts +++ b/clients/client-healthlake/src/protocols/Aws_json1_0.ts @@ -289,8 +289,7 @@ const deserializeAws_json1_0CreateFHIRDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -306,10 +305,12 @@ const deserializeAws_json1_0CreateFHIRDatastoreCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -341,8 +342,7 @@ const deserializeAws_json1_0DeleteFHIRDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -364,10 +364,12 @@ const deserializeAws_json1_0DeleteFHIRDatastoreCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -399,8 +401,7 @@ const deserializeAws_json1_0DescribeFHIRDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.healthlake#InternalServerException": @@ -416,10 +417,12 @@ const deserializeAws_json1_0DescribeFHIRDatastoreCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -451,8 +454,7 @@ const deserializeAws_json1_0DescribeFHIRExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.healthlake#InternalServerException": @@ -468,10 +470,12 @@ const deserializeAws_json1_0DescribeFHIRExportJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -503,8 +507,7 @@ const deserializeAws_json1_0DescribeFHIRImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.healthlake#InternalServerException": @@ -520,10 +523,12 @@ const deserializeAws_json1_0DescribeFHIRImportJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -555,8 +560,7 @@ const deserializeAws_json1_0ListFHIRDatastoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.healthlake#InternalServerException": @@ -569,10 +573,12 @@ const deserializeAws_json1_0ListFHIRDatastoresCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -604,8 +610,7 @@ const deserializeAws_json1_0ListFHIRExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -624,10 +629,12 @@ const deserializeAws_json1_0ListFHIRExportJobsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -659,8 +666,7 @@ const deserializeAws_json1_0ListFHIRImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -679,10 +685,12 @@ const deserializeAws_json1_0ListFHIRImportJobsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -714,8 +722,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.healthlake#ResourceNotFoundException": @@ -725,10 +732,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -760,8 +769,7 @@ const deserializeAws_json1_0StartFHIRExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -780,10 +788,12 @@ const deserializeAws_json1_0StartFHIRExportJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -815,8 +825,7 @@ const deserializeAws_json1_0StartFHIRImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.healthlake#AccessDeniedException": @@ -835,10 +844,12 @@ const deserializeAws_json1_0StartFHIRImportJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -870,8 +881,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.healthlake#ResourceNotFoundException": @@ -881,10 +891,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -916,8 +928,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.healthlake#ResourceNotFoundException": @@ -927,10 +938,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,7 +1690,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1703,6 +1716,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-honeycode/src/protocols/Aws_restJson1.ts b/clients/client-honeycode/src/protocols/Aws_restJson1.ts index 01249881b571e..91c9328d0e1f0 100644 --- a/clients/client-honeycode/src/protocols/Aws_restJson1.ts +++ b/clients/client-honeycode/src/protocols/Aws_restJson1.ts @@ -785,8 +785,7 @@ const deserializeAws_restJson1BatchCreateTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -814,10 +813,12 @@ const deserializeAws_restJson1BatchCreateTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -854,8 +855,7 @@ const deserializeAws_restJson1BatchDeleteTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -880,10 +880,12 @@ const deserializeAws_restJson1BatchDeleteTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -920,8 +922,7 @@ const deserializeAws_restJson1BatchUpdateTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -946,10 +947,12 @@ const deserializeAws_restJson1BatchUpdateTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -990,8 +993,7 @@ const deserializeAws_restJson1BatchUpsertTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1019,10 +1021,12 @@ const deserializeAws_restJson1BatchUpsertTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1067,8 +1071,7 @@ const deserializeAws_restJson1DescribeTableDataImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1093,10 +1096,12 @@ const deserializeAws_restJson1DescribeTableDataImportJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1137,8 +1142,7 @@ const deserializeAws_restJson1GetScreenDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1163,10 +1167,12 @@ const deserializeAws_restJson1GetScreenDataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1199,8 +1205,7 @@ const deserializeAws_restJson1InvokeScreenAutomationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1234,10 +1239,12 @@ const deserializeAws_restJson1InvokeScreenAutomationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1278,8 +1285,7 @@ const deserializeAws_restJson1ListTableColumnsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1304,10 +1310,12 @@ const deserializeAws_restJson1ListTableColumnsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1356,8 +1364,7 @@ const deserializeAws_restJson1ListTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1382,10 +1389,12 @@ const deserializeAws_restJson1ListTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1426,8 +1435,7 @@ const deserializeAws_restJson1ListTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1452,10 +1460,12 @@ const deserializeAws_restJson1ListTablesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1488,8 +1498,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1514,10 +1523,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1562,8 +1573,7 @@ const deserializeAws_restJson1QueryTableRowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1588,10 +1598,12 @@ const deserializeAws_restJson1QueryTableRowsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1628,8 +1640,7 @@ const deserializeAws_restJson1StartTableDataImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1657,10 +1668,12 @@ const deserializeAws_restJson1StartTableDataImportJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1689,8 +1702,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1715,10 +1727,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1747,8 +1761,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.honeycode#AccessDeniedException": @@ -1773,10 +1786,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2582,7 +2597,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2608,6 +2623,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iam/src/protocols/Aws_query.ts b/clients/client-iam/src/protocols/Aws_query.ts index 2d736c3e162d1..1fd73340e2f9c 100644 --- a/clients/client-iam/src/protocols/Aws_query.ts +++ b/clients/client-iam/src/protocols/Aws_query.ts @@ -3266,8 +3266,7 @@ const deserializeAws_queryAddClientIDToOpenIDConnectProviderCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -3283,10 +3282,12 @@ const deserializeAws_queryAddClientIDToOpenIDConnectProviderCommandError = async throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3315,8 +3316,7 @@ const deserializeAws_queryAddRoleToInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -3335,10 +3335,12 @@ const deserializeAws_queryAddRoleToInstanceProfileCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3367,8 +3369,7 @@ const deserializeAws_queryAddUserToGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -3381,10 +3382,12 @@ const deserializeAws_queryAddUserToGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3413,8 +3416,7 @@ const deserializeAws_queryAttachGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -3433,10 +3435,12 @@ const deserializeAws_queryAttachGroupPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3465,8 +3469,7 @@ const deserializeAws_queryAttachRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -3488,10 +3491,12 @@ const deserializeAws_queryAttachRolePolicyCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3520,8 +3525,7 @@ const deserializeAws_queryAttachUserPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -3540,10 +3544,12 @@ const deserializeAws_queryAttachUserPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3572,8 +3578,7 @@ const deserializeAws_queryChangePasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityTemporarilyUnmodifiableException": case "com.amazonaws.iam#EntityTemporarilyUnmodifiableException": @@ -3595,10 +3600,12 @@ const deserializeAws_queryChangePasswordCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3630,8 +3637,7 @@ const deserializeAws_queryCreateAccessKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -3644,10 +3650,12 @@ const deserializeAws_queryCreateAccessKeyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3676,8 +3684,7 @@ const deserializeAws_queryCreateAccountAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -3690,10 +3697,12 @@ const deserializeAws_queryCreateAccountAliasCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3725,8 +3734,7 @@ const deserializeAws_queryCreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -3742,10 +3750,12 @@ const deserializeAws_queryCreateGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3777,8 +3787,7 @@ const deserializeAws_queryCreateInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -3797,10 +3806,12 @@ const deserializeAws_queryCreateInstanceProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3832,8 +3843,7 @@ const deserializeAws_queryCreateLoginProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -3852,10 +3862,12 @@ const deserializeAws_queryCreateLoginProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3887,8 +3899,7 @@ const deserializeAws_queryCreateOpenIDConnectProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -3907,10 +3918,12 @@ const deserializeAws_queryCreateOpenIDConnectProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3942,8 +3955,7 @@ const deserializeAws_queryCreatePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -3965,10 +3977,12 @@ const deserializeAws_queryCreatePolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4000,8 +4014,7 @@ const deserializeAws_queryCreatePolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -4020,10 +4033,12 @@ const deserializeAws_queryCreatePolicyVersionCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4055,8 +4070,7 @@ const deserializeAws_queryCreateRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -4078,10 +4092,12 @@ const deserializeAws_queryCreateRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4113,8 +4129,7 @@ const deserializeAws_queryCreateSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -4133,10 +4148,12 @@ const deserializeAws_queryCreateSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4168,8 +4185,7 @@ const deserializeAws_queryCreateServiceLinkedRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -4185,10 +4201,12 @@ const deserializeAws_queryCreateServiceLinkedRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4223,8 +4241,7 @@ const deserializeAws_queryCreateServiceSpecificCredentialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -4237,10 +4254,12 @@ const deserializeAws_queryCreateServiceSpecificCredentialCommandError = async ( throw await deserializeAws_queryServiceNotSupportedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4272,8 +4291,7 @@ const deserializeAws_queryCreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -4295,10 +4313,12 @@ const deserializeAws_queryCreateUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4330,8 +4350,7 @@ const deserializeAws_queryCreateVirtualMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -4350,10 +4369,12 @@ const deserializeAws_queryCreateVirtualMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4382,8 +4403,7 @@ const deserializeAws_queryDeactivateMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityTemporarilyUnmodifiableException": case "com.amazonaws.iam#EntityTemporarilyUnmodifiableException": @@ -4399,10 +4419,12 @@ const deserializeAws_queryDeactivateMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4431,8 +4453,7 @@ const deserializeAws_queryDeleteAccessKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -4445,10 +4466,12 @@ const deserializeAws_queryDeleteAccessKeyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4477,8 +4500,7 @@ const deserializeAws_queryDeleteAccountAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -4491,10 +4513,12 @@ const deserializeAws_queryDeleteAccountAliasCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4523,8 +4547,7 @@ const deserializeAws_queryDeleteAccountPasswordPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -4537,10 +4560,12 @@ const deserializeAws_queryDeleteAccountPasswordPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4569,8 +4594,7 @@ const deserializeAws_queryDeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -4586,10 +4610,12 @@ const deserializeAws_queryDeleteGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4618,8 +4644,7 @@ const deserializeAws_queryDeleteGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -4632,10 +4657,12 @@ const deserializeAws_queryDeleteGroupPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4664,8 +4691,7 @@ const deserializeAws_queryDeleteInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -4681,10 +4707,12 @@ const deserializeAws_queryDeleteInstanceProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4713,8 +4741,7 @@ const deserializeAws_queryDeleteLoginProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityTemporarilyUnmodifiableException": case "com.amazonaws.iam#EntityTemporarilyUnmodifiableException": @@ -4730,10 +4757,12 @@ const deserializeAws_queryDeleteLoginProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4762,8 +4791,7 @@ const deserializeAws_queryDeleteOpenIDConnectProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -4776,10 +4804,12 @@ const deserializeAws_queryDeleteOpenIDConnectProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4808,8 +4838,7 @@ const deserializeAws_queryDeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -4828,10 +4857,12 @@ const deserializeAws_queryDeletePolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4860,8 +4891,7 @@ const deserializeAws_queryDeletePolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -4880,10 +4910,12 @@ const deserializeAws_queryDeletePolicyVersionCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4912,8 +4944,7 @@ const deserializeAws_queryDeleteRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -4935,10 +4966,12 @@ const deserializeAws_queryDeleteRoleCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4967,8 +5000,7 @@ const deserializeAws_queryDeleteRolePermissionsBoundaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -4981,10 +5013,12 @@ const deserializeAws_queryDeleteRolePermissionsBoundaryCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5013,8 +5047,7 @@ const deserializeAws_queryDeleteRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -5030,10 +5063,12 @@ const deserializeAws_queryDeleteRolePolicyCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5062,8 +5097,7 @@ const deserializeAws_queryDeleteSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -5079,10 +5113,12 @@ const deserializeAws_queryDeleteSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5111,8 +5147,7 @@ const deserializeAws_queryDeleteServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -5128,10 +5163,12 @@ const deserializeAws_queryDeleteServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5163,8 +5200,7 @@ const deserializeAws_queryDeleteServiceLinkedRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -5177,10 +5213,12 @@ const deserializeAws_queryDeleteServiceLinkedRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5209,18 +5247,19 @@ const deserializeAws_queryDeleteServiceSpecificCredentialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5249,8 +5288,7 @@ const deserializeAws_queryDeleteSigningCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -5263,10 +5301,12 @@ const deserializeAws_queryDeleteSigningCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5295,18 +5335,19 @@ const deserializeAws_queryDeleteSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5335,8 +5376,7 @@ const deserializeAws_queryDeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -5355,10 +5395,12 @@ const deserializeAws_queryDeleteUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5387,8 +5429,7 @@ const deserializeAws_queryDeleteUserPermissionsBoundaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -5398,10 +5439,12 @@ const deserializeAws_queryDeleteUserPermissionsBoundaryCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5430,8 +5473,7 @@ const deserializeAws_queryDeleteUserPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -5444,10 +5486,12 @@ const deserializeAws_queryDeleteUserPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5476,8 +5520,7 @@ const deserializeAws_queryDeleteVirtualMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iam#DeleteConflictException": @@ -5493,10 +5536,12 @@ const deserializeAws_queryDeleteVirtualMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5525,8 +5570,7 @@ const deserializeAws_queryDetachGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -5542,10 +5586,12 @@ const deserializeAws_queryDetachGroupPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5574,8 +5620,7 @@ const deserializeAws_queryDetachRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -5594,10 +5639,12 @@ const deserializeAws_queryDetachRolePolicyCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5626,8 +5673,7 @@ const deserializeAws_queryDetachUserPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -5643,10 +5689,12 @@ const deserializeAws_queryDetachUserPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5675,8 +5723,7 @@ const deserializeAws_queryEnableMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -5698,10 +5745,12 @@ const deserializeAws_queryEnableMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5733,8 +5782,7 @@ const deserializeAws_queryGenerateCredentialReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -5744,10 +5792,12 @@ const deserializeAws_queryGenerateCredentialReportCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5782,18 +5832,19 @@ const deserializeAws_queryGenerateOrganizationsAccessReportCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReportGenerationLimitExceededException": case "com.amazonaws.iam#ReportGenerationLimitExceededException": throw await deserializeAws_queryReportGenerationLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5828,8 +5879,7 @@ const deserializeAws_queryGenerateServiceLastAccessedDetailsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -5839,10 +5889,12 @@ const deserializeAws_queryGenerateServiceLastAccessedDetailsCommandError = async throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5874,18 +5926,19 @@ const deserializeAws_queryGetAccessKeyLastUsedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5920,18 +5973,19 @@ const deserializeAws_queryGetAccountAuthorizationDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5963,8 +6017,7 @@ const deserializeAws_queryGetAccountPasswordPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -5974,10 +6027,12 @@ const deserializeAws_queryGetAccountPasswordPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6009,18 +6064,19 @@ const deserializeAws_queryGetAccountSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6052,18 +6108,19 @@ const deserializeAws_queryGetContextKeysForCustomPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": throw await deserializeAws_queryInvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6095,8 +6152,7 @@ const deserializeAws_queryGetContextKeysForPrincipalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6106,10 +6162,12 @@ const deserializeAws_queryGetContextKeysForPrincipalPolicyCommandError = async ( throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6141,8 +6199,7 @@ const deserializeAws_queryGetCredentialReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CredentialReportExpiredException": case "com.amazonaws.iam#CredentialReportExpiredException": @@ -6158,10 +6215,12 @@ const deserializeAws_queryGetCredentialReportCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6193,8 +6252,7 @@ const deserializeAws_queryGetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6204,10 +6262,12 @@ const deserializeAws_queryGetGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6239,8 +6299,7 @@ const deserializeAws_queryGetGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6250,10 +6309,12 @@ const deserializeAws_queryGetGroupPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6285,8 +6346,7 @@ const deserializeAws_queryGetInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6296,10 +6356,12 @@ const deserializeAws_queryGetInstanceProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6331,8 +6393,7 @@ const deserializeAws_queryGetLoginProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6342,10 +6403,12 @@ const deserializeAws_queryGetLoginProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6377,8 +6440,7 @@ const deserializeAws_queryGetOpenIDConnectProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6391,10 +6453,12 @@ const deserializeAws_queryGetOpenIDConnectProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6426,18 +6490,19 @@ const deserializeAws_queryGetOrganizationsAccessReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6469,8 +6534,7 @@ const deserializeAws_queryGetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6483,10 +6547,12 @@ const deserializeAws_queryGetPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6518,8 +6584,7 @@ const deserializeAws_queryGetPolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6532,10 +6597,12 @@ const deserializeAws_queryGetPolicyVersionCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6567,8 +6634,7 @@ const deserializeAws_queryGetRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6578,10 +6644,12 @@ const deserializeAws_queryGetRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6613,8 +6681,7 @@ const deserializeAws_queryGetRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6624,10 +6691,12 @@ const deserializeAws_queryGetRolePolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6659,8 +6728,7 @@ const deserializeAws_queryGetSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6673,10 +6741,12 @@ const deserializeAws_queryGetSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6708,8 +6778,7 @@ const deserializeAws_queryGetServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6719,10 +6788,12 @@ const deserializeAws_queryGetServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6757,8 +6828,7 @@ const deserializeAws_queryGetServiceLastAccessedDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6768,10 +6838,12 @@ const deserializeAws_queryGetServiceLastAccessedDetailsCommandError = async ( throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6806,8 +6878,7 @@ const deserializeAws_queryGetServiceLastAccessedDetailsWithEntitiesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6817,10 +6888,12 @@ const deserializeAws_queryGetServiceLastAccessedDetailsWithEntitiesCommandError throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6855,8 +6928,7 @@ const deserializeAws_queryGetServiceLinkedRoleDeletionStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -6869,10 +6941,12 @@ const deserializeAws_queryGetServiceLinkedRoleDeletionStatusCommandError = async throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6904,8 +6978,7 @@ const deserializeAws_queryGetSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6915,10 +6988,12 @@ const deserializeAws_queryGetSSHPublicKeyCommandError = async ( throw await deserializeAws_queryUnrecognizedPublicKeyEncodingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6950,8 +7025,7 @@ const deserializeAws_queryGetUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -6961,10 +7035,12 @@ const deserializeAws_queryGetUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6996,8 +7072,7 @@ const deserializeAws_queryGetUserPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7007,10 +7082,12 @@ const deserializeAws_queryGetUserPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7042,8 +7119,7 @@ const deserializeAws_queryListAccessKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7053,10 +7129,12 @@ const deserializeAws_queryListAccessKeysCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7088,18 +7166,19 @@ const deserializeAws_queryListAccountAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7131,8 +7210,7 @@ const deserializeAws_queryListAttachedGroupPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7145,10 +7223,12 @@ const deserializeAws_queryListAttachedGroupPoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7180,8 +7260,7 @@ const deserializeAws_queryListAttachedRolePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7194,10 +7273,12 @@ const deserializeAws_queryListAttachedRolePoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7229,8 +7310,7 @@ const deserializeAws_queryListAttachedUserPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7243,10 +7323,12 @@ const deserializeAws_queryListAttachedUserPoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7278,8 +7360,7 @@ const deserializeAws_queryListEntitiesForPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7292,10 +7373,12 @@ const deserializeAws_queryListEntitiesForPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7327,8 +7410,7 @@ const deserializeAws_queryListGroupPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7338,10 +7420,12 @@ const deserializeAws_queryListGroupPoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7373,18 +7457,19 @@ const deserializeAws_queryListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7416,8 +7501,7 @@ const deserializeAws_queryListGroupsForUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7427,10 +7511,12 @@ const deserializeAws_queryListGroupsForUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7462,18 +7548,19 @@ const deserializeAws_queryListInstanceProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7505,8 +7592,7 @@ const deserializeAws_queryListInstanceProfilesForRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7516,10 +7602,12 @@ const deserializeAws_queryListInstanceProfilesForRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7551,8 +7639,7 @@ const deserializeAws_queryListInstanceProfileTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7562,10 +7649,12 @@ const deserializeAws_queryListInstanceProfileTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7597,8 +7686,7 @@ const deserializeAws_queryListMFADevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7608,10 +7696,12 @@ const deserializeAws_queryListMFADevicesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7643,8 +7733,7 @@ const deserializeAws_queryListMFADeviceTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7657,10 +7746,12 @@ const deserializeAws_queryListMFADeviceTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7692,18 +7783,19 @@ const deserializeAws_queryListOpenIDConnectProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7738,8 +7830,7 @@ const deserializeAws_queryListOpenIDConnectProviderTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7752,10 +7843,12 @@ const deserializeAws_queryListOpenIDConnectProviderTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7787,18 +7880,19 @@ const deserializeAws_queryListPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7833,8 +7927,7 @@ const deserializeAws_queryListPoliciesGrantingServiceAccessCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7844,10 +7937,12 @@ const deserializeAws_queryListPoliciesGrantingServiceAccessCommandError = async throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7879,8 +7974,7 @@ const deserializeAws_queryListPolicyTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7893,10 +7987,12 @@ const deserializeAws_queryListPolicyTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7928,8 +8024,7 @@ const deserializeAws_queryListPolicyVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -7942,10 +8037,12 @@ const deserializeAws_queryListPolicyVersionsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7977,8 +8074,7 @@ const deserializeAws_queryListRolePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -7988,10 +8084,12 @@ const deserializeAws_queryListRolePoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8023,18 +8121,19 @@ const deserializeAws_queryListRolesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8066,8 +8165,7 @@ const deserializeAws_queryListRoleTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8077,10 +8175,12 @@ const deserializeAws_queryListRoleTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8112,18 +8212,19 @@ const deserializeAws_queryListSAMLProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8155,8 +8256,7 @@ const deserializeAws_queryListSAMLProviderTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -8169,10 +8269,12 @@ const deserializeAws_queryListSAMLProviderTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8204,18 +8306,19 @@ const deserializeAws_queryListServerCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8247,8 +8350,7 @@ const deserializeAws_queryListServerCertificateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8258,10 +8360,12 @@ const deserializeAws_queryListServerCertificateTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8296,8 +8400,7 @@ const deserializeAws_queryListServiceSpecificCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8307,10 +8410,12 @@ const deserializeAws_queryListServiceSpecificCredentialsCommandError = async ( throw await deserializeAws_queryServiceNotSupportedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8342,8 +8447,7 @@ const deserializeAws_queryListSigningCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8353,10 +8457,12 @@ const deserializeAws_queryListSigningCertificatesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8388,18 +8494,19 @@ const deserializeAws_queryListSSHPublicKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8431,8 +8538,7 @@ const deserializeAws_queryListUserPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8442,10 +8548,12 @@ const deserializeAws_queryListUserPoliciesCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8477,18 +8585,19 @@ const deserializeAws_queryListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8520,8 +8629,7 @@ const deserializeAws_queryListUserTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -8531,10 +8639,12 @@ const deserializeAws_queryListUserTagsCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8566,15 +8676,16 @@ const deserializeAws_queryListVirtualMFADevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8603,8 +8714,7 @@ const deserializeAws_queryPutGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -8620,10 +8730,12 @@ const deserializeAws_queryPutGroupPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8652,8 +8764,7 @@ const deserializeAws_queryPutRolePermissionsBoundaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -8672,10 +8783,12 @@ const deserializeAws_queryPutRolePermissionsBoundaryCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8704,8 +8817,7 @@ const deserializeAws_queryPutRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -8724,10 +8836,12 @@ const deserializeAws_queryPutRolePolicyCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8756,8 +8870,7 @@ const deserializeAws_queryPutUserPermissionsBoundaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -8773,10 +8886,12 @@ const deserializeAws_queryPutUserPermissionsBoundaryCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8805,8 +8920,7 @@ const deserializeAws_queryPutUserPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -8822,10 +8936,12 @@ const deserializeAws_queryPutUserPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8854,8 +8970,7 @@ const deserializeAws_queryRemoveClientIDFromOpenIDConnectProviderCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -8868,10 +8983,12 @@ const deserializeAws_queryRemoveClientIDFromOpenIDConnectProviderCommandError = throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8900,8 +9017,7 @@ const deserializeAws_queryRemoveRoleFromInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -8917,10 +9033,12 @@ const deserializeAws_queryRemoveRoleFromInstanceProfileCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8949,8 +9067,7 @@ const deserializeAws_queryRemoveUserFromGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -8963,10 +9080,12 @@ const deserializeAws_queryRemoveUserFromGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9001,18 +9120,19 @@ const deserializeAws_queryResetServiceSpecificCredentialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9041,8 +9161,7 @@ const deserializeAws_queryResyncMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAuthenticationCodeException": case "com.amazonaws.iam#InvalidAuthenticationCodeException": @@ -9058,10 +9177,12 @@ const deserializeAws_queryResyncMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9090,8 +9211,7 @@ const deserializeAws_querySetDefaultPolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -9107,10 +9227,12 @@ const deserializeAws_querySetDefaultPolicyVersionCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9139,18 +9261,19 @@ const deserializeAws_querySetSecurityTokenServicePreferencesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceFailureException": case "com.amazonaws.iam#ServiceFailureException": throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9182,8 +9305,7 @@ const deserializeAws_querySimulateCustomPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -9193,10 +9315,12 @@ const deserializeAws_querySimulateCustomPolicyCommandError = async ( throw await deserializeAws_queryPolicyEvaluationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9228,8 +9352,7 @@ const deserializeAws_querySimulatePrincipalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -9242,10 +9365,12 @@ const deserializeAws_querySimulatePrincipalPolicyCommandError = async ( throw await deserializeAws_queryPolicyEvaluationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9274,8 +9399,7 @@ const deserializeAws_queryTagInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9294,10 +9418,12 @@ const deserializeAws_queryTagInstanceProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9326,8 +9452,7 @@ const deserializeAws_queryTagMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9346,10 +9471,12 @@ const deserializeAws_queryTagMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9378,8 +9505,7 @@ const deserializeAws_queryTagOpenIDConnectProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9398,10 +9524,12 @@ const deserializeAws_queryTagOpenIDConnectProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9430,8 +9558,7 @@ const deserializeAws_queryTagPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9450,10 +9577,12 @@ const deserializeAws_queryTagPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9482,8 +9611,7 @@ const deserializeAws_queryTagRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9502,10 +9630,12 @@ const deserializeAws_queryTagRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9534,8 +9664,7 @@ const deserializeAws_queryTagSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9554,10 +9683,12 @@ const deserializeAws_queryTagSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9586,8 +9717,7 @@ const deserializeAws_queryTagServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9606,10 +9736,12 @@ const deserializeAws_queryTagServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9638,8 +9770,7 @@ const deserializeAws_queryTagUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9658,10 +9789,12 @@ const deserializeAws_queryTagUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9690,8 +9823,7 @@ const deserializeAws_queryUntagInstanceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9707,10 +9839,12 @@ const deserializeAws_queryUntagInstanceProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9739,8 +9873,7 @@ const deserializeAws_queryUntagMFADeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9756,10 +9889,12 @@ const deserializeAws_queryUntagMFADeviceCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9788,8 +9923,7 @@ const deserializeAws_queryUntagOpenIDConnectProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9805,10 +9939,12 @@ const deserializeAws_queryUntagOpenIDConnectProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9837,8 +9973,7 @@ const deserializeAws_queryUntagPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9854,10 +9989,12 @@ const deserializeAws_queryUntagPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9886,8 +10023,7 @@ const deserializeAws_queryUntagRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9900,10 +10036,12 @@ const deserializeAws_queryUntagRoleCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9932,8 +10070,7 @@ const deserializeAws_queryUntagSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9949,10 +10086,12 @@ const deserializeAws_queryUntagSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9981,8 +10120,7 @@ const deserializeAws_queryUntagServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -9998,10 +10136,12 @@ const deserializeAws_queryUntagServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10030,8 +10170,7 @@ const deserializeAws_queryUntagUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -10044,10 +10183,12 @@ const deserializeAws_queryUntagUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10076,8 +10217,7 @@ const deserializeAws_queryUpdateAccessKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -10090,10 +10230,12 @@ const deserializeAws_queryUpdateAccessKeyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10122,8 +10264,7 @@ const deserializeAws_queryUpdateAccountPasswordPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -10139,10 +10280,12 @@ const deserializeAws_queryUpdateAccountPasswordPolicyCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10171,8 +10314,7 @@ const deserializeAws_queryUpdateAssumeRolePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -10191,10 +10333,12 @@ const deserializeAws_queryUpdateAssumeRolePolicyCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10223,8 +10367,7 @@ const deserializeAws_queryUpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -10240,10 +10383,12 @@ const deserializeAws_queryUpdateGroupCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10272,8 +10417,7 @@ const deserializeAws_queryUpdateLoginProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityTemporarilyUnmodifiableException": case "com.amazonaws.iam#EntityTemporarilyUnmodifiableException": @@ -10292,10 +10436,12 @@ const deserializeAws_queryUpdateLoginProfileCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10324,8 +10470,7 @@ const deserializeAws_queryUpdateOpenIDConnectProviderThumbprintCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -10338,10 +10483,12 @@ const deserializeAws_queryUpdateOpenIDConnectProviderThumbprintCommandError = as throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10373,8 +10520,7 @@ const deserializeAws_queryUpdateRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -10387,10 +10533,12 @@ const deserializeAws_queryUpdateRoleCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10422,8 +10570,7 @@ const deserializeAws_queryUpdateRoleDescriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": @@ -10436,10 +10583,12 @@ const deserializeAws_queryUpdateRoleDescriptionCommandError = async ( throw await deserializeAws_queryUnmodifiableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10471,8 +10620,7 @@ const deserializeAws_queryUpdateSAMLProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.iam#InvalidInputException": @@ -10488,10 +10636,12 @@ const deserializeAws_queryUpdateSAMLProviderCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10520,8 +10670,7 @@ const deserializeAws_queryUpdateServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.iam#EntityAlreadyExistsException": @@ -10537,10 +10686,12 @@ const deserializeAws_queryUpdateServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10569,18 +10720,19 @@ const deserializeAws_queryUpdateServiceSpecificCredentialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10609,8 +10761,7 @@ const deserializeAws_queryUpdateSigningCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iam#LimitExceededException": @@ -10623,10 +10774,12 @@ const deserializeAws_queryUpdateSigningCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10655,18 +10808,19 @@ const deserializeAws_queryUpdateSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchEntityException": case "com.amazonaws.iam#NoSuchEntityException": throw await deserializeAws_queryNoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10695,8 +10849,7 @@ const deserializeAws_queryUpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -10718,10 +10871,12 @@ const deserializeAws_queryUpdateUserCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10753,8 +10908,7 @@ const deserializeAws_queryUploadServerCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.iam#ConcurrentModificationException": @@ -10779,10 +10933,12 @@ const deserializeAws_queryUploadServerCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10814,8 +10970,7 @@ const deserializeAws_queryUploadSigningCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateCertificateException": case "com.amazonaws.iam#DuplicateCertificateException": @@ -10840,10 +10995,12 @@ const deserializeAws_queryUploadSigningCertificateCommandError = async ( throw await deserializeAws_queryServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10875,8 +11032,7 @@ const deserializeAws_queryUploadSSHPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateSSHPublicKeyException": case "com.amazonaws.iam#DuplicateSSHPublicKeyException": @@ -10895,10 +11051,12 @@ const deserializeAws_queryUploadSSHPublicKeyCommandError = async ( throw await deserializeAws_queryUnrecognizedPublicKeyEncodingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -17842,12 +18000,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-identitystore/src/protocols/Aws_json1_1.ts b/clients/client-identitystore/src/protocols/Aws_json1_1.ts index ba116e6ebfbd3..85b4d52136270 100644 --- a/clients/client-identitystore/src/protocols/Aws_json1_1.ts +++ b/clients/client-identitystore/src/protocols/Aws_json1_1.ts @@ -113,8 +113,7 @@ const deserializeAws_json1_1DescribeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.identitystore#AccessDeniedException": @@ -133,10 +132,12 @@ const deserializeAws_json1_1DescribeGroupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -168,8 +169,7 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.identitystore#AccessDeniedException": @@ -188,10 +188,12 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -223,8 +225,7 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.identitystore#AccessDeniedException": @@ -243,10 +244,12 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -278,8 +281,7 @@ const deserializeAws_json1_1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.identitystore#AccessDeniedException": @@ -298,10 +300,12 @@ const deserializeAws_json1_1ListUsersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -599,7 +603,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -625,6 +629,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-imagebuilder/src/protocols/Aws_restJson1.ts b/clients/client-imagebuilder/src/protocols/Aws_restJson1.ts index de6976cde98ab..f01b56273f844 100644 --- a/clients/client-imagebuilder/src/protocols/Aws_restJson1.ts +++ b/clients/client-imagebuilder/src/protocols/Aws_restJson1.ts @@ -1764,8 +1764,7 @@ const deserializeAws_restJson1CancelImageCreationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -1793,10 +1792,12 @@ const deserializeAws_restJson1CancelImageCreationCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1837,8 +1838,7 @@ const deserializeAws_restJson1CreateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -1875,10 +1875,12 @@ const deserializeAws_restJson1CreateComponentCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1919,8 +1921,7 @@ const deserializeAws_restJson1CreateContainerRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -1957,10 +1958,12 @@ const deserializeAws_restJson1CreateContainerRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2001,8 +2004,7 @@ const deserializeAws_restJson1CreateDistributionConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2039,10 +2041,12 @@ const deserializeAws_restJson1CreateDistributionConfigurationCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2083,8 +2087,7 @@ const deserializeAws_restJson1CreateImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2115,10 +2118,12 @@ const deserializeAws_restJson1CreateImageCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2159,8 +2164,7 @@ const deserializeAws_restJson1CreateImagePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2194,10 +2198,12 @@ const deserializeAws_restJson1CreateImagePipelineCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2238,8 +2244,7 @@ const deserializeAws_restJson1CreateImageRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2276,10 +2281,12 @@ const deserializeAws_restJson1CreateImageRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2320,8 +2327,7 @@ const deserializeAws_restJson1CreateInfrastructureConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2355,10 +2361,12 @@ const deserializeAws_restJson1CreateInfrastructureConfigurationCommandError = as throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2395,8 +2403,7 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2421,10 +2428,12 @@ const deserializeAws_restJson1DeleteComponentCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2461,8 +2470,7 @@ const deserializeAws_restJson1DeleteContainerRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2487,10 +2495,12 @@ const deserializeAws_restJson1DeleteContainerRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2527,8 +2537,7 @@ const deserializeAws_restJson1DeleteDistributionConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2553,10 +2562,12 @@ const deserializeAws_restJson1DeleteDistributionConfigurationCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2593,8 +2604,7 @@ const deserializeAws_restJson1DeleteImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2619,10 +2629,12 @@ const deserializeAws_restJson1DeleteImageCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2659,8 +2671,7 @@ const deserializeAws_restJson1DeleteImagePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2685,10 +2696,12 @@ const deserializeAws_restJson1DeleteImagePipelineCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2725,8 +2738,7 @@ const deserializeAws_restJson1DeleteImageRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2751,10 +2763,12 @@ const deserializeAws_restJson1DeleteImageRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2791,8 +2805,7 @@ const deserializeAws_restJson1DeleteInfrastructureConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2817,10 +2830,12 @@ const deserializeAws_restJson1DeleteInfrastructureConfigurationCommandError = as throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2857,8 +2872,7 @@ const deserializeAws_restJson1GetComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2880,10 +2894,12 @@ const deserializeAws_restJson1GetComponentCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2920,8 +2936,7 @@ const deserializeAws_restJson1GetComponentPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -2943,10 +2958,12 @@ const deserializeAws_restJson1GetComponentPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2983,8 +3000,7 @@ const deserializeAws_restJson1GetContainerRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3006,10 +3022,12 @@ const deserializeAws_restJson1GetContainerRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3046,8 +3064,7 @@ const deserializeAws_restJson1GetContainerRecipePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3069,10 +3086,12 @@ const deserializeAws_restJson1GetContainerRecipePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3112,8 +3131,7 @@ const deserializeAws_restJson1GetDistributionConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3135,10 +3153,12 @@ const deserializeAws_restJson1GetDistributionConfigurationCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3175,8 +3195,7 @@ const deserializeAws_restJson1GetImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3198,10 +3217,12 @@ const deserializeAws_restJson1GetImageCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3238,8 +3259,7 @@ const deserializeAws_restJson1GetImagePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3261,10 +3281,12 @@ const deserializeAws_restJson1GetImagePipelineCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3301,8 +3323,7 @@ const deserializeAws_restJson1GetImagePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3324,10 +3345,12 @@ const deserializeAws_restJson1GetImagePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3364,8 +3387,7 @@ const deserializeAws_restJson1GetImageRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3387,10 +3409,12 @@ const deserializeAws_restJson1GetImageRecipeCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3427,8 +3451,7 @@ const deserializeAws_restJson1GetImageRecipePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3450,10 +3473,12 @@ const deserializeAws_restJson1GetImageRecipePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3493,8 +3518,7 @@ const deserializeAws_restJson1GetInfrastructureConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3516,10 +3540,12 @@ const deserializeAws_restJson1GetInfrastructureConfigurationCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3560,8 +3586,7 @@ const deserializeAws_restJson1ImportComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3595,10 +3620,12 @@ const deserializeAws_restJson1ImportComponentCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3639,8 +3666,7 @@ const deserializeAws_restJson1ImportVmImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientException": case "com.amazonaws.imagebuilder#ClientException": @@ -3653,10 +3679,12 @@ const deserializeAws_restJson1ImportVmImageCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3697,8 +3725,7 @@ const deserializeAws_restJson1ListComponentBuildVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3723,10 +3750,12 @@ const deserializeAws_restJson1ListComponentBuildVersionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3767,8 +3796,7 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3793,10 +3821,12 @@ const deserializeAws_restJson1ListComponentsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3840,8 +3870,7 @@ const deserializeAws_restJson1ListContainerRecipesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3866,10 +3895,12 @@ const deserializeAws_restJson1ListContainerRecipesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3913,8 +3944,7 @@ const deserializeAws_restJson1ListDistributionConfigurationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -3939,10 +3969,12 @@ const deserializeAws_restJson1ListDistributionConfigurationsCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3983,8 +4015,7 @@ const deserializeAws_restJson1ListImageBuildVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4009,10 +4040,12 @@ const deserializeAws_restJson1ListImageBuildVersionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4053,8 +4086,7 @@ const deserializeAws_restJson1ListImagePackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4082,10 +4114,12 @@ const deserializeAws_restJson1ListImagePackagesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4126,8 +4160,7 @@ const deserializeAws_restJson1ListImagePipelineImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4155,10 +4188,12 @@ const deserializeAws_restJson1ListImagePipelineImagesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4199,8 +4234,7 @@ const deserializeAws_restJson1ListImagePipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4225,10 +4259,12 @@ const deserializeAws_restJson1ListImagePipelinesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4272,8 +4308,7 @@ const deserializeAws_restJson1ListImageRecipesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4298,10 +4333,12 @@ const deserializeAws_restJson1ListImageRecipesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4342,8 +4379,7 @@ const deserializeAws_restJson1ListImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4368,10 +4404,12 @@ const deserializeAws_restJson1ListImagesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4418,8 +4456,7 @@ const deserializeAws_restJson1ListInfrastructureConfigurationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4444,10 +4481,12 @@ const deserializeAws_restJson1ListInfrastructureConfigurationsCommandError = asy throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4480,8 +4519,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.imagebuilder#InvalidParameterException": @@ -4494,10 +4532,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4534,8 +4574,7 @@ const deserializeAws_restJson1PutComponentPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4563,10 +4602,12 @@ const deserializeAws_restJson1PutComponentPolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4603,8 +4644,7 @@ const deserializeAws_restJson1PutContainerRecipePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4632,10 +4672,12 @@ const deserializeAws_restJson1PutContainerRecipePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4672,8 +4714,7 @@ const deserializeAws_restJson1PutImagePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4701,10 +4742,12 @@ const deserializeAws_restJson1PutImagePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4741,8 +4784,7 @@ const deserializeAws_restJson1PutImageRecipePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4770,10 +4812,12 @@ const deserializeAws_restJson1PutImageRecipePolicyCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4814,8 +4858,7 @@ const deserializeAws_restJson1StartImagePipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -4846,10 +4889,12 @@ const deserializeAws_restJson1StartImagePipelineExecutionCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4878,8 +4923,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.imagebuilder#InvalidParameterException": @@ -4892,10 +4936,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4924,8 +4970,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.imagebuilder#InvalidParameterException": @@ -4938,10 +4983,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4982,8 +5029,7 @@ const deserializeAws_restJson1UpdateDistributionConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -5014,10 +5060,12 @@ const deserializeAws_restJson1UpdateDistributionConfigurationCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5058,8 +5106,7 @@ const deserializeAws_restJson1UpdateImagePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -5087,10 +5134,12 @@ const deserializeAws_restJson1UpdateImagePipelineCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5131,8 +5180,7 @@ const deserializeAws_restJson1UpdateInfrastructureConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CallRateLimitExceededException": case "com.amazonaws.imagebuilder#CallRateLimitExceededException": @@ -5160,10 +5208,12 @@ const deserializeAws_restJson1UpdateInfrastructureConfigurationCommandError = as throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7185,7 +7235,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7211,6 +7261,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-inspector/src/protocols/Aws_json1_1.ts b/clients/client-inspector/src/protocols/Aws_json1_1.ts index 501f842d5f77e..de8171eb85a7c 100644 --- a/clients/client-inspector/src/protocols/Aws_json1_1.ts +++ b/clients/client-inspector/src/protocols/Aws_json1_1.ts @@ -755,8 +755,7 @@ const deserializeAws_json1_1AddAttributesToFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -775,10 +774,12 @@ const deserializeAws_json1_1AddAttributesToFindingsCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -810,8 +811,7 @@ const deserializeAws_json1_1CreateAssessmentTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -836,10 +836,12 @@ const deserializeAws_json1_1CreateAssessmentTargetCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -871,8 +873,7 @@ const deserializeAws_json1_1CreateAssessmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -894,10 +895,12 @@ const deserializeAws_json1_1CreateAssessmentTemplateCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -929,8 +932,7 @@ const deserializeAws_json1_1CreateExclusionsPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -952,10 +954,12 @@ const deserializeAws_json1_1CreateExclusionsPreviewCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -987,8 +991,7 @@ const deserializeAws_json1_1CreateResourceGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1007,10 +1010,12 @@ const deserializeAws_json1_1CreateResourceGroupCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1039,8 +1044,7 @@ const deserializeAws_json1_1DeleteAssessmentRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1062,10 +1066,12 @@ const deserializeAws_json1_1DeleteAssessmentRunCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1094,8 +1100,7 @@ const deserializeAws_json1_1DeleteAssessmentTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1117,10 +1122,12 @@ const deserializeAws_json1_1DeleteAssessmentTargetCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1149,8 +1156,7 @@ const deserializeAws_json1_1DeleteAssessmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1172,10 +1178,12 @@ const deserializeAws_json1_1DeleteAssessmentTemplateCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1207,8 +1215,7 @@ const deserializeAws_json1_1DescribeAssessmentRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1218,10 +1225,12 @@ const deserializeAws_json1_1DescribeAssessmentRunsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1253,8 +1262,7 @@ const deserializeAws_json1_1DescribeAssessmentTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1264,10 +1272,12 @@ const deserializeAws_json1_1DescribeAssessmentTargetsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1299,8 +1309,7 @@ const deserializeAws_json1_1DescribeAssessmentTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1310,10 +1319,12 @@ const deserializeAws_json1_1DescribeAssessmentTemplatesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1345,18 +1356,19 @@ const deserializeAws_json1_1DescribeCrossAccountAccessRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": throw await deserializeAws_json1_1InternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1388,8 +1400,7 @@ const deserializeAws_json1_1DescribeExclusionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1399,10 +1410,12 @@ const deserializeAws_json1_1DescribeExclusionsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1434,8 +1447,7 @@ const deserializeAws_json1_1DescribeFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1445,10 +1457,12 @@ const deserializeAws_json1_1DescribeFindingsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1480,8 +1494,7 @@ const deserializeAws_json1_1DescribeResourceGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1491,10 +1504,12 @@ const deserializeAws_json1_1DescribeResourceGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1526,8 +1541,7 @@ const deserializeAws_json1_1DescribeRulesPackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.inspector#InternalException": @@ -1537,10 +1551,12 @@ const deserializeAws_json1_1DescribeRulesPackagesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1572,8 +1588,7 @@ const deserializeAws_json1_1GetAssessmentReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1598,10 +1613,12 @@ const deserializeAws_json1_1GetAssessmentReportCommandError = async ( throw await deserializeAws_json1_1UnsupportedFeatureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1633,8 +1650,7 @@ const deserializeAws_json1_1GetExclusionsPreviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1650,10 +1666,12 @@ const deserializeAws_json1_1GetExclusionsPreviewCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1685,8 +1703,7 @@ const deserializeAws_json1_1GetTelemetryMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1702,10 +1719,12 @@ const deserializeAws_json1_1GetTelemetryMetadataCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1737,8 +1756,7 @@ const deserializeAws_json1_1ListAssessmentRunAgentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1754,10 +1772,12 @@ const deserializeAws_json1_1ListAssessmentRunAgentsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1789,8 +1809,7 @@ const deserializeAws_json1_1ListAssessmentRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1806,10 +1825,12 @@ const deserializeAws_json1_1ListAssessmentRunsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1841,8 +1862,7 @@ const deserializeAws_json1_1ListAssessmentTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1855,10 +1875,12 @@ const deserializeAws_json1_1ListAssessmentTargetsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1890,8 +1912,7 @@ const deserializeAws_json1_1ListAssessmentTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1907,10 +1928,12 @@ const deserializeAws_json1_1ListAssessmentTemplatesCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1942,8 +1965,7 @@ const deserializeAws_json1_1ListEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -1959,10 +1981,12 @@ const deserializeAws_json1_1ListEventSubscriptionsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1994,8 +2018,7 @@ const deserializeAws_json1_1ListExclusionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2011,10 +2034,12 @@ const deserializeAws_json1_1ListExclusionsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2046,8 +2071,7 @@ const deserializeAws_json1_1ListFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2063,10 +2087,12 @@ const deserializeAws_json1_1ListFindingsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2098,8 +2124,7 @@ const deserializeAws_json1_1ListRulesPackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2112,10 +2137,12 @@ const deserializeAws_json1_1ListRulesPackagesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2147,8 +2174,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2164,10 +2190,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2199,8 +2227,7 @@ const deserializeAws_json1_1PreviewAgentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2219,10 +2246,12 @@ const deserializeAws_json1_1PreviewAgentsCommandError = async ( throw await deserializeAws_json1_1NoSuchEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2280,7 @@ const deserializeAws_json1_1RegisterCrossAccountAccessRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2271,10 +2299,12 @@ const deserializeAws_json1_1RegisterCrossAccountAccessRoleCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2306,8 +2336,7 @@ const deserializeAws_json1_1RemoveAttributesFromFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2326,10 +2355,12 @@ const deserializeAws_json1_1RemoveAttributesFromFindingsCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2358,8 +2389,7 @@ const deserializeAws_json1_1SetTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2378,10 +2408,12 @@ const deserializeAws_json1_1SetTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2413,8 +2445,7 @@ const deserializeAws_json1_1StartAssessmentRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2442,10 +2473,12 @@ const deserializeAws_json1_1StartAssessmentRunCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2474,8 +2507,7 @@ const deserializeAws_json1_1StopAssessmentRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2494,10 +2526,12 @@ const deserializeAws_json1_1StopAssessmentRunCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2526,8 +2560,7 @@ const deserializeAws_json1_1SubscribeToEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2549,10 +2582,12 @@ const deserializeAws_json1_1SubscribeToEventCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2581,8 +2616,7 @@ const deserializeAws_json1_1UnsubscribeFromEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2601,10 +2635,12 @@ const deserializeAws_json1_1UnsubscribeFromEventCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2633,8 +2669,7 @@ const deserializeAws_json1_1UpdateAssessmentTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector#AccessDeniedException": @@ -2653,10 +2688,12 @@ const deserializeAws_json1_1UpdateAssessmentTargetCommandError = async ( throw await deserializeAws_json1_1ServiceTemporarilyUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4879,7 +4916,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4905,6 +4942,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-inspector2/src/protocols/Aws_restJson1.ts b/clients/client-inspector2/src/protocols/Aws_restJson1.ts index 8994466d9d709..1bcb71b15ef21 100644 --- a/clients/client-inspector2/src/protocols/Aws_restJson1.ts +++ b/clients/client-inspector2/src/protocols/Aws_restJson1.ts @@ -1040,8 +1040,7 @@ const deserializeAws_restJson1AssociateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1057,10 +1056,12 @@ const deserializeAws_restJson1AssociateMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1097,8 +1098,7 @@ const deserializeAws_restJson1BatchGetAccountStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1117,10 +1117,12 @@ const deserializeAws_restJson1BatchGetAccountStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1157,8 +1159,7 @@ const deserializeAws_restJson1BatchGetFreeTrialInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1174,10 +1175,12 @@ const deserializeAws_restJson1BatchGetFreeTrialInfoCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1210,8 +1213,7 @@ const deserializeAws_restJson1CancelFindingsReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1230,10 +1232,12 @@ const deserializeAws_restJson1CancelFindingsReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1266,8 +1270,7 @@ const deserializeAws_restJson1CreateFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1289,10 +1292,12 @@ const deserializeAws_restJson1CreateFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1325,8 +1330,7 @@ const deserializeAws_restJson1CreateFindingsReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1345,10 +1349,12 @@ const deserializeAws_restJson1CreateFindingsReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1381,8 +1387,7 @@ const deserializeAws_restJson1DeleteFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1401,10 +1406,12 @@ const deserializeAws_restJson1DeleteFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1441,8 +1448,7 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1458,10 +1464,12 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1498,8 +1506,7 @@ const deserializeAws_restJson1DisableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1518,10 +1525,12 @@ const deserializeAws_restJson1DisableCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1554,8 +1563,7 @@ const deserializeAws_restJson1DisableDelegatedAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1577,10 +1585,12 @@ const deserializeAws_restJson1DisableDelegatedAdminAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1613,8 +1623,7 @@ const deserializeAws_restJson1DisassociateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1630,10 +1639,12 @@ const deserializeAws_restJson1DisassociateMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1670,8 +1681,7 @@ const deserializeAws_restJson1EnableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1690,10 +1700,12 @@ const deserializeAws_restJson1EnableCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1726,8 +1738,7 @@ const deserializeAws_restJson1EnableDelegatedAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1749,10 +1760,12 @@ const deserializeAws_restJson1EnableDelegatedAdminAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1785,8 +1798,7 @@ const deserializeAws_restJson1GetDelegatedAdminAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1805,10 +1817,12 @@ const deserializeAws_restJson1GetDelegatedAdminAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1861,8 +1875,7 @@ const deserializeAws_restJson1GetFindingsReportStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1881,10 +1894,12 @@ const deserializeAws_restJson1GetFindingsReportStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1917,8 +1932,7 @@ const deserializeAws_restJson1GetMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1937,10 +1951,12 @@ const deserializeAws_restJson1GetMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1993,7 @@ const deserializeAws_restJson1ListAccountPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -1994,10 +2009,12 @@ const deserializeAws_restJson1ListAccountPermissionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2034,8 +2051,7 @@ const deserializeAws_restJson1ListCoverageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2048,10 +2064,12 @@ const deserializeAws_restJson1ListCoverageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2092,8 +2110,7 @@ const deserializeAws_restJson1ListCoverageStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2106,10 +2123,12 @@ const deserializeAws_restJson1ListCoverageStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2149,8 +2168,7 @@ const deserializeAws_restJson1ListDelegatedAdminAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2166,10 +2184,12 @@ const deserializeAws_restJson1ListDelegatedAdminAccountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2206,8 +2226,7 @@ const deserializeAws_restJson1ListFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2223,10 +2242,12 @@ const deserializeAws_restJson1ListFiltersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2267,8 +2288,7 @@ const deserializeAws_restJson1ListFindingAggregationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2281,10 +2301,12 @@ const deserializeAws_restJson1ListFindingAggregationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2321,8 +2343,7 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2335,10 +2356,12 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2375,8 +2398,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2392,10 +2414,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2428,8 +2452,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2445,10 +2468,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2485,8 +2510,7 @@ const deserializeAws_restJson1ListUsageTotalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2502,10 +2526,12 @@ const deserializeAws_restJson1ListUsageTotalsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2534,8 +2560,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.inspector2#BadRequestException": @@ -2554,10 +2579,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2586,8 +2613,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.inspector2#InternalServerException": @@ -2603,10 +2629,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2639,8 +2667,7 @@ const deserializeAws_restJson1UpdateFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2659,10 +2686,12 @@ const deserializeAws_restJson1UpdateFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2695,8 +2724,7 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.inspector2#AccessDeniedException": @@ -2712,10 +2740,12 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4892,7 +4922,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4918,6 +4948,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-1click-devices-service/src/protocols/Aws_restJson1.ts b/clients/client-iot-1click-devices-service/src/protocols/Aws_restJson1.ts index 21e7b050a7a09..8234cefbd94e5 100644 --- a/clients/client-iot-1click-devices-service/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-1click-devices-service/src/protocols/Aws_restJson1.ts @@ -496,8 +496,7 @@ const deserializeAws_restJson1ClaimDevicesByClaimCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.iot1clickdevicesservice#ForbiddenException": @@ -510,10 +509,12 @@ const deserializeAws_restJson1ClaimDevicesByClaimCodeCommandError = async ( throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -546,8 +547,7 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -560,10 +560,12 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -596,8 +598,7 @@ const deserializeAws_restJson1FinalizeDeviceClaimCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -616,10 +617,12 @@ const deserializeAws_restJson1FinalizeDeviceClaimCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -652,8 +655,7 @@ const deserializeAws_restJson1GetDeviceMethodsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -666,10 +668,12 @@ const deserializeAws_restJson1GetDeviceMethodsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -702,8 +706,7 @@ const deserializeAws_restJson1InitiateDeviceClaimCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -719,10 +722,12 @@ const deserializeAws_restJson1InitiateDeviceClaimCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -755,8 +760,7 @@ const deserializeAws_restJson1InvokeDeviceMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -778,10 +782,12 @@ const deserializeAws_restJson1InvokeDeviceMethodCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -818,8 +824,7 @@ const deserializeAws_restJson1ListDeviceEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -835,10 +840,12 @@ const deserializeAws_restJson1ListDeviceEventsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -875,8 +882,7 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -889,10 +895,12 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( throw await deserializeAws_restJson1RangeNotSatisfiableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -925,8 +933,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -936,10 +943,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -968,8 +977,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -982,10 +990,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1018,8 +1028,7 @@ const deserializeAws_restJson1UnclaimDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -1032,10 +1041,12 @@ const deserializeAws_restJson1UnclaimDeviceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1064,8 +1075,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -1078,10 +1088,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1110,8 +1122,7 @@ const deserializeAws_restJson1UpdateDeviceStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickdevicesservice#InternalFailureException": @@ -1124,10 +1135,12 @@ const deserializeAws_restJson1UpdateDeviceStateCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1435,7 +1448,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1461,6 +1474,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-1click-projects/src/protocols/Aws_restJson1.ts b/clients/client-iot-1click-projects/src/protocols/Aws_restJson1.ts index 849602f95f434..faed4c88ae7ee 100644 --- a/clients/client-iot-1click-projects/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-1click-projects/src/protocols/Aws_restJson1.ts @@ -658,8 +658,7 @@ const deserializeAws_restJson1AssociateDeviceWithPlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -675,10 +674,12 @@ const deserializeAws_restJson1AssociateDeviceWithPlacementCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -707,8 +708,7 @@ const deserializeAws_restJson1CreatePlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -724,10 +724,12 @@ const deserializeAws_restJson1CreatePlacementCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -756,8 +758,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -770,10 +771,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -802,8 +805,7 @@ const deserializeAws_restJson1DeletePlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -819,10 +821,12 @@ const deserializeAws_restJson1DeletePlacementCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -851,8 +855,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -868,10 +871,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -904,8 +909,7 @@ const deserializeAws_restJson1DescribePlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -918,10 +922,12 @@ const deserializeAws_restJson1DescribePlacementCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -954,8 +960,7 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -968,10 +973,12 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1000,8 +1007,7 @@ const deserializeAws_restJson1DisassociateDeviceFromPlacementCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1017,10 +1023,12 @@ const deserializeAws_restJson1DisassociateDeviceFromPlacementCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1053,8 +1061,7 @@ const deserializeAws_restJson1GetDevicesInPlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1067,10 +1074,12 @@ const deserializeAws_restJson1GetDevicesInPlacementCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1107,8 +1116,7 @@ const deserializeAws_restJson1ListPlacementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1121,10 +1129,12 @@ const deserializeAws_restJson1ListPlacementsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1161,8 +1171,7 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1172,10 +1181,12 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1208,8 +1219,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1222,10 +1232,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,8 +1266,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1268,10 +1279,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1313,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1314,10 +1326,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1346,8 +1360,7 @@ const deserializeAws_restJson1UpdatePlacementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1363,10 +1376,12 @@ const deserializeAws_restJson1UpdatePlacementCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1395,8 +1410,7 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot1clickprojects#InternalFailureException": @@ -1412,10 +1426,12 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1853,7 +1869,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1879,6 +1895,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-data-plane/src/protocols/Aws_restJson1.ts b/clients/client-iot-data-plane/src/protocols/Aws_restJson1.ts index 959fd8e768391..94ed11bffc7c0 100644 --- a/clients/client-iot-data-plane/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-data-plane/src/protocols/Aws_restJson1.ts @@ -297,8 +297,7 @@ const deserializeAws_restJson1DeleteThingShadowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -326,10 +325,12 @@ const deserializeAws_restJson1DeleteThingShadowCommandError = async ( throw await deserializeAws_restJson1UnsupportedDocumentEncodingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -374,8 +375,7 @@ const deserializeAws_restJson1GetRetainedMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -400,10 +400,12 @@ const deserializeAws_restJson1GetRetainedMessageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -434,8 +436,7 @@ const deserializeAws_restJson1GetThingShadowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -463,10 +464,12 @@ const deserializeAws_restJson1GetThingShadowCommandError = async ( throw await deserializeAws_restJson1UnsupportedDocumentEncodingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -507,8 +510,7 @@ const deserializeAws_restJson1ListNamedShadowsForThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -533,10 +535,12 @@ const deserializeAws_restJson1ListNamedShadowsForThingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -573,8 +577,7 @@ const deserializeAws_restJson1ListRetainedMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -596,10 +599,12 @@ const deserializeAws_restJson1ListRetainedMessagesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -628,8 +633,7 @@ const deserializeAws_restJson1PublishCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotdataplane#InternalFailureException": @@ -645,10 +649,12 @@ const deserializeAws_restJson1PublishCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -679,8 +685,7 @@ const deserializeAws_restJson1UpdateThingShadowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotdataplane#ConflictException": @@ -711,10 +716,12 @@ const deserializeAws_restJson1UpdateThingShadowCommandError = async ( throw await deserializeAws_restJson1UnsupportedDocumentEncodingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -956,7 +963,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -982,6 +989,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts b/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts index cf3659d21f437..47bfebda80358 100644 --- a/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-events-data/src/protocols/Aws_restJson1.ts @@ -459,8 +459,7 @@ const deserializeAws_restJson1BatchAcknowledgeAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -476,10 +475,12 @@ const deserializeAws_restJson1BatchAcknowledgeAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -515,8 +516,7 @@ const deserializeAws_restJson1BatchDeleteDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -532,10 +532,12 @@ const deserializeAws_restJson1BatchDeleteDetectorCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -568,8 +570,7 @@ const deserializeAws_restJson1BatchDisableAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -585,10 +586,12 @@ const deserializeAws_restJson1BatchDisableAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -621,8 +624,7 @@ const deserializeAws_restJson1BatchEnableAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -638,10 +640,12 @@ const deserializeAws_restJson1BatchEnableAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -677,8 +681,7 @@ const deserializeAws_restJson1BatchPutMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -694,10 +697,12 @@ const deserializeAws_restJson1BatchPutMessageCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -730,8 +735,7 @@ const deserializeAws_restJson1BatchResetAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -747,10 +751,12 @@ const deserializeAws_restJson1BatchResetAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -783,8 +789,7 @@ const deserializeAws_restJson1BatchSnoozeAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -800,10 +805,12 @@ const deserializeAws_restJson1BatchSnoozeAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -839,8 +846,7 @@ const deserializeAws_restJson1BatchUpdateDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -856,10 +862,12 @@ const deserializeAws_restJson1BatchUpdateDetectorCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -892,8 +900,7 @@ const deserializeAws_restJson1DescribeAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -912,10 +919,12 @@ const deserializeAws_restJson1DescribeAlarmCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -948,8 +957,7 @@ const deserializeAws_restJson1DescribeDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -968,10 +976,12 @@ const deserializeAws_restJson1DescribeDetectorCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1008,8 +1018,7 @@ const deserializeAws_restJson1ListAlarmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -1028,10 +1037,12 @@ const deserializeAws_restJson1ListAlarmsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1068,8 +1079,7 @@ const deserializeAws_restJson1ListDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.ioteventsdata#InternalFailureException": @@ -1088,10 +1098,12 @@ const deserializeAws_restJson1ListDetectorsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1862,7 +1874,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1888,6 +1900,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-events/src/protocols/Aws_restJson1.ts b/clients/client-iot-events/src/protocols/Aws_restJson1.ts index 1976c9ec0482e..8fc97fc7f42f3 100644 --- a/clients/client-iot-events/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-events/src/protocols/Aws_restJson1.ts @@ -1003,8 +1003,7 @@ const deserializeAws_restJson1CreateAlarmModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1029,10 +1028,12 @@ const deserializeAws_restJson1CreateAlarmModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1068,8 +1069,7 @@ const deserializeAws_restJson1CreateDetectorModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1094,10 +1094,12 @@ const deserializeAws_restJson1CreateDetectorModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1130,8 +1132,7 @@ const deserializeAws_restJson1CreateInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1150,10 +1151,12 @@ const deserializeAws_restJson1CreateInputCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1185,7 @@ const deserializeAws_restJson1DeleteAlarmModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1205,10 +1207,12 @@ const deserializeAws_restJson1DeleteAlarmModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1237,8 +1241,7 @@ const deserializeAws_restJson1DeleteDetectorModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1260,10 +1263,12 @@ const deserializeAws_restJson1DeleteDetectorModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1292,8 +1297,7 @@ const deserializeAws_restJson1DeleteInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1315,10 +1319,12 @@ const deserializeAws_restJson1DeleteInputCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1407,8 +1413,7 @@ const deserializeAws_restJson1DescribeAlarmModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1427,10 +1432,12 @@ const deserializeAws_restJson1DescribeAlarmModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1463,8 +1470,7 @@ const deserializeAws_restJson1DescribeDetectorModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1483,10 +1489,12 @@ const deserializeAws_restJson1DescribeDetectorModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1519,8 +1527,7 @@ const deserializeAws_restJson1DescribeDetectorModelAnalysisCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1539,10 +1546,12 @@ const deserializeAws_restJson1DescribeDetectorModelAnalysisCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1575,8 +1584,7 @@ const deserializeAws_restJson1DescribeInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1595,10 +1603,12 @@ const deserializeAws_restJson1DescribeInputCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1641,7 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1654,10 +1663,12 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1705,7 @@ const deserializeAws_restJson1GetDetectorModelAnalysisResultsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1714,10 +1724,12 @@ const deserializeAws_restJson1GetDetectorModelAnalysisResultsCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1754,8 +1766,7 @@ const deserializeAws_restJson1ListAlarmModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1771,10 +1782,12 @@ const deserializeAws_restJson1ListAlarmModelsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1827,7 @@ const deserializeAws_restJson1ListAlarmModelVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1834,10 +1846,12 @@ const deserializeAws_restJson1ListAlarmModelVersionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1877,8 +1891,7 @@ const deserializeAws_restJson1ListDetectorModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1894,10 +1907,12 @@ const deserializeAws_restJson1ListDetectorModelsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1937,8 +1952,7 @@ const deserializeAws_restJson1ListDetectorModelVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -1957,10 +1971,12 @@ const deserializeAws_restJson1ListDetectorModelVersionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1997,8 +2013,7 @@ const deserializeAws_restJson1ListInputRoutingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2017,10 +2032,12 @@ const deserializeAws_restJson1ListInputRoutingsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2057,8 +2074,7 @@ const deserializeAws_restJson1ListInputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2074,10 +2090,12 @@ const deserializeAws_restJson1ListInputsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2110,8 +2128,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2130,10 +2147,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2162,8 +2181,7 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2185,10 +2203,12 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2221,8 +2241,7 @@ const deserializeAws_restJson1StartDetectorModelAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2241,10 +2260,12 @@ const deserializeAws_restJson1StartDetectorModelAnalysisCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,8 +2294,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2296,10 +2316,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2328,8 +2350,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2348,10 +2369,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2400,8 +2423,7 @@ const deserializeAws_restJson1UpdateAlarmModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2423,10 +2445,12 @@ const deserializeAws_restJson1UpdateAlarmModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2462,8 +2486,7 @@ const deserializeAws_restJson1UpdateDetectorModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2485,10 +2508,12 @@ const deserializeAws_restJson1UpdateDetectorModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2521,8 +2546,7 @@ const deserializeAws_restJson1UpdateInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotevents#InternalFailureException": @@ -2544,10 +2568,12 @@ const deserializeAws_restJson1UpdateInputCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4359,7 +4385,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4385,6 +4411,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-jobs-data-plane/src/protocols/Aws_restJson1.ts b/clients/client-iot-jobs-data-plane/src/protocols/Aws_restJson1.ts index 3e0e6ccfa081e..c190695f8348c 100644 --- a/clients/client-iot-jobs-data-plane/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-jobs-data-plane/src/protocols/Aws_restJson1.ts @@ -235,8 +235,7 @@ const deserializeAws_restJson1DescribeJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iotjobsdataplane#CertificateValidationException": @@ -258,10 +257,12 @@ const deserializeAws_restJson1DescribeJobExecutionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -298,8 +299,7 @@ const deserializeAws_restJson1GetPendingJobExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iotjobsdataplane#CertificateValidationException": @@ -318,10 +318,12 @@ const deserializeAws_restJson1GetPendingJobExecutionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -354,8 +356,7 @@ const deserializeAws_restJson1StartNextPendingJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iotjobsdataplane#CertificateValidationException": @@ -374,10 +375,12 @@ const deserializeAws_restJson1StartNextPendingJobExecutionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -414,8 +417,7 @@ const deserializeAws_restJson1UpdateJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iotjobsdataplane#CertificateValidationException": @@ -437,10 +439,12 @@ const deserializeAws_restJson1UpdateJobExecutionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -678,7 +682,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -704,6 +708,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot-wireless/src/protocols/Aws_restJson1.ts b/clients/client-iot-wireless/src/protocols/Aws_restJson1.ts index ce35928556114..205a420ecf07a 100644 --- a/clients/client-iot-wireless/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot-wireless/src/protocols/Aws_restJson1.ts @@ -3377,8 +3377,7 @@ const deserializeAws_restJson1AssociateAwsAccountWithPartnerAccountCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3400,10 +3399,12 @@ const deserializeAws_restJson1AssociateAwsAccountWithPartnerAccountCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3432,8 +3433,7 @@ const deserializeAws_restJson1AssociateMulticastGroupWithFuotaTaskCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3455,10 +3455,12 @@ const deserializeAws_restJson1AssociateMulticastGroupWithFuotaTaskCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3487,8 +3489,7 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithFuotaTaskCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3510,10 +3511,12 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithFuotaTaskCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3542,8 +3545,7 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithMulticastGroupCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3565,10 +3567,12 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithMulticastGroupCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3597,8 +3601,7 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithThingCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3620,10 +3623,12 @@ const deserializeAws_restJson1AssociateWirelessDeviceWithThingCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3656,8 +3661,7 @@ const deserializeAws_restJson1AssociateWirelessGatewayWithCertificateCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3679,10 +3683,12 @@ const deserializeAws_restJson1AssociateWirelessGatewayWithCertificateCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3711,8 +3717,7 @@ const deserializeAws_restJson1AssociateWirelessGatewayWithThingCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3734,10 +3739,12 @@ const deserializeAws_restJson1AssociateWirelessGatewayWithThingCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3766,8 +3773,7 @@ const deserializeAws_restJson1CancelMulticastGroupSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3789,10 +3795,12 @@ const deserializeAws_restJson1CancelMulticastGroupSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3829,8 +3837,7 @@ const deserializeAws_restJson1CreateDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3852,10 +3859,12 @@ const deserializeAws_restJson1CreateDestinationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3892,8 +3901,7 @@ const deserializeAws_restJson1CreateDeviceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3912,10 +3920,12 @@ const deserializeAws_restJson1CreateDeviceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3952,8 +3962,7 @@ const deserializeAws_restJson1CreateFuotaTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -3975,10 +3984,12 @@ const deserializeAws_restJson1CreateFuotaTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4015,8 +4026,7 @@ const deserializeAws_restJson1CreateMulticastGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4038,10 +4048,12 @@ const deserializeAws_restJson1CreateMulticastGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4078,8 +4090,7 @@ const deserializeAws_restJson1CreateNetworkAnalyzerConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4101,10 +4112,12 @@ const deserializeAws_restJson1CreateNetworkAnalyzerConfigurationCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4141,8 +4154,7 @@ const deserializeAws_restJson1CreateServiceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4161,10 +4173,12 @@ const deserializeAws_restJson1CreateServiceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4201,8 +4215,7 @@ const deserializeAws_restJson1CreateWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4224,10 +4237,12 @@ const deserializeAws_restJson1CreateWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4264,8 +4279,7 @@ const deserializeAws_restJson1CreateWirelessGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4284,10 +4298,12 @@ const deserializeAws_restJson1CreateWirelessGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4324,8 +4340,7 @@ const deserializeAws_restJson1CreateWirelessGatewayTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4347,10 +4362,12 @@ const deserializeAws_restJson1CreateWirelessGatewayTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4387,8 +4404,7 @@ const deserializeAws_restJson1CreateWirelessGatewayTaskDefinitionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4410,10 +4426,12 @@ const deserializeAws_restJson1CreateWirelessGatewayTaskDefinitionCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4442,8 +4460,7 @@ const deserializeAws_restJson1DeleteDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4465,10 +4482,12 @@ const deserializeAws_restJson1DeleteDestinationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4497,8 +4516,7 @@ const deserializeAws_restJson1DeleteDeviceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4520,10 +4538,12 @@ const deserializeAws_restJson1DeleteDeviceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4552,8 +4572,7 @@ const deserializeAws_restJson1DeleteFuotaTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4572,10 +4591,12 @@ const deserializeAws_restJson1DeleteFuotaTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4604,8 +4625,7 @@ const deserializeAws_restJson1DeleteMulticastGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4627,10 +4647,12 @@ const deserializeAws_restJson1DeleteMulticastGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4659,8 +4681,7 @@ const deserializeAws_restJson1DeleteNetworkAnalyzerConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4682,10 +4703,12 @@ const deserializeAws_restJson1DeleteNetworkAnalyzerConfigurationCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4714,8 +4737,7 @@ const deserializeAws_restJson1DeleteQueuedMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4734,10 +4756,12 @@ const deserializeAws_restJson1DeleteQueuedMessagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4766,8 +4790,7 @@ const deserializeAws_restJson1DeleteServiceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4789,10 +4812,12 @@ const deserializeAws_restJson1DeleteServiceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4821,8 +4846,7 @@ const deserializeAws_restJson1DeleteWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4841,10 +4865,12 @@ const deserializeAws_restJson1DeleteWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4873,8 +4899,7 @@ const deserializeAws_restJson1DeleteWirelessGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4893,10 +4918,12 @@ const deserializeAws_restJson1DeleteWirelessGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4925,8 +4952,7 @@ const deserializeAws_restJson1DeleteWirelessGatewayTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4945,10 +4971,12 @@ const deserializeAws_restJson1DeleteWirelessGatewayTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4977,8 +5005,7 @@ const deserializeAws_restJson1DeleteWirelessGatewayTaskDefinitionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -4997,10 +5024,12 @@ const deserializeAws_restJson1DeleteWirelessGatewayTaskDefinitionCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5029,8 +5058,7 @@ const deserializeAws_restJson1DisassociateAwsAccountFromPartnerAccountCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -5046,10 +5074,12 @@ const deserializeAws_restJson1DisassociateAwsAccountFromPartnerAccountCommandErr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5078,8 +5108,7 @@ const deserializeAws_restJson1DisassociateMulticastGroupFromFuotaTaskCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5098,10 +5127,12 @@ const deserializeAws_restJson1DisassociateMulticastGroupFromFuotaTaskCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5130,8 +5161,7 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromFuotaTaskCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5153,10 +5183,12 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromFuotaTaskCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5185,8 +5217,7 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromMulticastGroupComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5205,10 +5236,12 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromMulticastGroupComman throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5237,8 +5270,7 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromThingCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5260,10 +5292,12 @@ const deserializeAws_restJson1DisassociateWirelessDeviceFromThingCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5292,8 +5326,7 @@ const deserializeAws_restJson1DisassociateWirelessGatewayFromCertificateCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5312,10 +5345,12 @@ const deserializeAws_restJson1DisassociateWirelessGatewayFromCertificateCommandE throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5344,8 +5379,7 @@ const deserializeAws_restJson1DisassociateWirelessGatewayFromThingCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5367,10 +5401,12 @@ const deserializeAws_restJson1DisassociateWirelessGatewayFromThingCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5423,8 +5459,7 @@ const deserializeAws_restJson1GetDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5443,10 +5478,12 @@ const deserializeAws_restJson1GetDestinationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5491,8 +5528,7 @@ const deserializeAws_restJson1GetDeviceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5511,10 +5547,12 @@ const deserializeAws_restJson1GetDeviceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5565,8 +5603,7 @@ const deserializeAws_restJson1GetEventConfigurationByResourceTypesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5579,10 +5616,12 @@ const deserializeAws_restJson1GetEventConfigurationByResourceTypesCommandError = throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5647,8 +5686,7 @@ const deserializeAws_restJson1GetFuotaTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5667,10 +5705,12 @@ const deserializeAws_restJson1GetFuotaTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5717,8 +5757,7 @@ const deserializeAws_restJson1GetLogLevelsByResourceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5737,10 +5776,12 @@ const deserializeAws_restJson1GetLogLevelsByResourceTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5797,8 +5838,7 @@ const deserializeAws_restJson1GetMulticastGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5817,10 +5857,12 @@ const deserializeAws_restJson1GetMulticastGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5853,8 +5895,7 @@ const deserializeAws_restJson1GetMulticastGroupSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5873,10 +5914,12 @@ const deserializeAws_restJson1GetMulticastGroupSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5929,8 +5972,7 @@ const deserializeAws_restJson1GetNetworkAnalyzerConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -5949,10 +5991,12 @@ const deserializeAws_restJson1GetNetworkAnalyzerConfigurationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5989,8 +6033,7 @@ const deserializeAws_restJson1GetPartnerAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -6006,10 +6049,12 @@ const deserializeAws_restJson1GetPartnerAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6060,8 +6105,7 @@ const deserializeAws_restJson1GetResourceEventConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6080,10 +6124,12 @@ const deserializeAws_restJson1GetResourceEventConfigurationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6116,8 +6162,7 @@ const deserializeAws_restJson1GetResourceLogLevelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6136,10 +6181,12 @@ const deserializeAws_restJson1GetResourceLogLevelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6180,8 +6227,7 @@ const deserializeAws_restJson1GetServiceEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6197,10 +6243,12 @@ const deserializeAws_restJson1GetServiceEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6245,8 +6293,7 @@ const deserializeAws_restJson1GetServiceProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6265,10 +6312,12 @@ const deserializeAws_restJson1GetServiceProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6337,8 +6386,7 @@ const deserializeAws_restJson1GetWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6357,10 +6405,12 @@ const deserializeAws_restJson1GetWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6405,8 +6455,7 @@ const deserializeAws_restJson1GetWirelessDeviceStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6425,10 +6474,12 @@ const deserializeAws_restJson1GetWirelessDeviceStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6485,8 +6536,7 @@ const deserializeAws_restJson1GetWirelessGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6505,10 +6555,12 @@ const deserializeAws_restJson1GetWirelessGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6545,8 +6597,7 @@ const deserializeAws_restJson1GetWirelessGatewayCertificateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6565,10 +6616,12 @@ const deserializeAws_restJson1GetWirelessGatewayCertificateCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6601,8 +6654,7 @@ const deserializeAws_restJson1GetWirelessGatewayFirmwareInformationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6621,10 +6673,12 @@ const deserializeAws_restJson1GetWirelessGatewayFirmwareInformationCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6665,8 +6719,7 @@ const deserializeAws_restJson1GetWirelessGatewayStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6685,10 +6738,12 @@ const deserializeAws_restJson1GetWirelessGatewayStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6737,8 +6792,7 @@ const deserializeAws_restJson1GetWirelessGatewayTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6757,10 +6811,12 @@ const deserializeAws_restJson1GetWirelessGatewayTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6805,8 +6861,7 @@ const deserializeAws_restJson1GetWirelessGatewayTaskDefinitionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6825,10 +6880,12 @@ const deserializeAws_restJson1GetWirelessGatewayTaskDefinitionCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6865,8 +6922,7 @@ const deserializeAws_restJson1ListDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6882,10 +6938,12 @@ const deserializeAws_restJson1ListDestinationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6922,8 +6980,7 @@ const deserializeAws_restJson1ListDeviceProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6939,10 +6996,12 @@ const deserializeAws_restJson1ListDeviceProfilesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6982,8 +7041,7 @@ const deserializeAws_restJson1ListEventConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -6999,10 +7057,12 @@ const deserializeAws_restJson1ListEventConfigurationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7039,8 +7099,7 @@ const deserializeAws_restJson1ListFuotaTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7056,10 +7115,12 @@ const deserializeAws_restJson1ListFuotaTasksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7096,8 +7157,7 @@ const deserializeAws_restJson1ListMulticastGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7113,10 +7173,12 @@ const deserializeAws_restJson1ListMulticastGroupsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7156,8 +7218,7 @@ const deserializeAws_restJson1ListMulticastGroupsByFuotaTaskCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7176,10 +7237,12 @@ const deserializeAws_restJson1ListMulticastGroupsByFuotaTaskCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7219,8 +7282,7 @@ const deserializeAws_restJson1ListNetworkAnalyzerConfigurationsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7236,10 +7298,12 @@ const deserializeAws_restJson1ListNetworkAnalyzerConfigurationsCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7276,8 +7340,7 @@ const deserializeAws_restJson1ListPartnerAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -7293,10 +7356,12 @@ const deserializeAws_restJson1ListPartnerAccountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7336,8 +7401,7 @@ const deserializeAws_restJson1ListQueuedMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7356,10 +7420,12 @@ const deserializeAws_restJson1ListQueuedMessagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7396,8 +7462,7 @@ const deserializeAws_restJson1ListServiceProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7413,10 +7478,12 @@ const deserializeAws_restJson1ListServiceProfilesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7449,8 +7516,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotwireless#ConflictException": @@ -7469,10 +7535,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7512,8 +7580,7 @@ const deserializeAws_restJson1ListWirelessDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7529,10 +7596,12 @@ const deserializeAws_restJson1ListWirelessDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7572,8 +7641,7 @@ const deserializeAws_restJson1ListWirelessGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7589,10 +7657,12 @@ const deserializeAws_restJson1ListWirelessGatewaysCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7629,8 +7699,7 @@ const deserializeAws_restJson1ListWirelessGatewayTaskDefinitionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7646,10 +7715,12 @@ const deserializeAws_restJson1ListWirelessGatewayTaskDefinitionsCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7678,8 +7749,7 @@ const deserializeAws_restJson1PutResourceLogLevelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7698,10 +7768,12 @@ const deserializeAws_restJson1PutResourceLogLevelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7730,8 +7802,7 @@ const deserializeAws_restJson1ResetAllResourceLogLevelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7750,10 +7821,12 @@ const deserializeAws_restJson1ResetAllResourceLogLevelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7782,8 +7855,7 @@ const deserializeAws_restJson1ResetResourceLogLevelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7802,10 +7874,12 @@ const deserializeAws_restJson1ResetResourceLogLevelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7838,8 +7912,7 @@ const deserializeAws_restJson1SendDataToMulticastGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7861,10 +7934,12 @@ const deserializeAws_restJson1SendDataToMulticastGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7897,8 +7972,7 @@ const deserializeAws_restJson1SendDataToWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -7914,10 +7988,12 @@ const deserializeAws_restJson1SendDataToWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7946,8 +8022,7 @@ const deserializeAws_restJson1StartBulkAssociateWirelessDeviceWithMulticastGroup body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -7966,10 +8041,12 @@ const deserializeAws_restJson1StartBulkAssociateWirelessDeviceWithMulticastGroup throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7998,8 +8075,7 @@ const deserializeAws_restJson1StartBulkDisassociateWirelessDeviceFromMulticastGr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8018,10 +8094,12 @@ const deserializeAws_restJson1StartBulkDisassociateWirelessDeviceFromMulticastGr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8050,8 +8128,7 @@ const deserializeAws_restJson1StartFuotaTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8073,10 +8150,12 @@ const deserializeAws_restJson1StartFuotaTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8105,8 +8184,7 @@ const deserializeAws_restJson1StartMulticastGroupSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8128,10 +8206,12 @@ const deserializeAws_restJson1StartMulticastGroupSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8160,8 +8240,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotwireless#ConflictException": @@ -8183,10 +8262,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8219,8 +8300,7 @@ const deserializeAws_restJson1TestWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -8236,10 +8316,12 @@ const deserializeAws_restJson1TestWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8268,8 +8350,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotwireless#ConflictException": @@ -8288,10 +8369,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8320,8 +8403,7 @@ const deserializeAws_restJson1UpdateDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8340,10 +8422,12 @@ const deserializeAws_restJson1UpdateDestinationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8372,8 +8456,7 @@ const deserializeAws_restJson1UpdateEventConfigurationByResourceTypesCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8389,10 +8472,12 @@ const deserializeAws_restJson1UpdateEventConfigurationByResourceTypesCommandErro throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8421,8 +8506,7 @@ const deserializeAws_restJson1UpdateFuotaTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8444,10 +8528,12 @@ const deserializeAws_restJson1UpdateFuotaTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8476,8 +8562,7 @@ const deserializeAws_restJson1UpdateLogLevelsByResourceTypesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8499,10 +8584,12 @@ const deserializeAws_restJson1UpdateLogLevelsByResourceTypesCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8531,8 +8618,7 @@ const deserializeAws_restJson1UpdateMulticastGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8554,10 +8640,12 @@ const deserializeAws_restJson1UpdateMulticastGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8586,8 +8674,7 @@ const deserializeAws_restJson1UpdateNetworkAnalyzerConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8606,10 +8693,12 @@ const deserializeAws_restJson1UpdateNetworkAnalyzerConfigurationCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8638,8 +8727,7 @@ const deserializeAws_restJson1UpdatePartnerAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotwireless#InternalServerException": @@ -8655,10 +8743,12 @@ const deserializeAws_restJson1UpdatePartnerAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8687,8 +8777,7 @@ const deserializeAws_restJson1UpdateResourceEventConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8710,10 +8799,12 @@ const deserializeAws_restJson1UpdateResourceEventConfigurationCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8742,8 +8833,7 @@ const deserializeAws_restJson1UpdateWirelessDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8762,10 +8852,12 @@ const deserializeAws_restJson1UpdateWirelessDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8794,8 +8886,7 @@ const deserializeAws_restJson1UpdateWirelessGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iotwireless#AccessDeniedException": @@ -8814,10 +8905,12 @@ const deserializeAws_restJson1UpdateWirelessGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10774,7 +10867,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -10800,6 +10893,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iot/src/protocols/Aws_restJson1.ts b/clients/client-iot/src/protocols/Aws_restJson1.ts index 06fa8f389857f..d79dd6fd84103 100644 --- a/clients/client-iot/src/protocols/Aws_restJson1.ts +++ b/clients/client-iot/src/protocols/Aws_restJson1.ts @@ -8622,8 +8622,7 @@ const deserializeAws_restJson1AcceptCertificateTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8648,10 +8647,12 @@ const deserializeAws_restJson1AcceptCertificateTransferCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8680,8 +8681,7 @@ const deserializeAws_restJson1AddThingToBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8697,10 +8697,12 @@ const deserializeAws_restJson1AddThingToBillingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8729,8 +8731,7 @@ const deserializeAws_restJson1AddThingToThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8746,10 +8747,12 @@ const deserializeAws_restJson1AddThingToThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8790,8 +8793,7 @@ const deserializeAws_restJson1AssociateTargetsWithJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -8810,10 +8812,12 @@ const deserializeAws_restJson1AssociateTargetsWithJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8842,8 +8846,7 @@ const deserializeAws_restJson1AttachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8868,10 +8871,12 @@ const deserializeAws_restJson1AttachPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8900,8 +8905,7 @@ const deserializeAws_restJson1AttachPrincipalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8926,10 +8930,12 @@ const deserializeAws_restJson1AttachPrincipalPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8958,8 +8964,7 @@ const deserializeAws_restJson1AttachSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -8981,10 +8986,12 @@ const deserializeAws_restJson1AttachSecurityProfileCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9013,8 +9020,7 @@ const deserializeAws_restJson1AttachThingPrincipalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9036,10 +9042,12 @@ const deserializeAws_restJson1AttachThingPrincipalCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9068,8 +9076,7 @@ const deserializeAws_restJson1CancelAuditMitigationActionsTaskCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9085,10 +9092,12 @@ const deserializeAws_restJson1CancelAuditMitigationActionsTaskCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9117,8 +9126,7 @@ const deserializeAws_restJson1CancelAuditTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9134,10 +9142,12 @@ const deserializeAws_restJson1CancelAuditTaskCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9166,8 +9176,7 @@ const deserializeAws_restJson1CancelCertificateTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9192,10 +9201,12 @@ const deserializeAws_restJson1CancelCertificateTransferCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9224,8 +9235,7 @@ const deserializeAws_restJson1CancelDetectMitigationActionsTaskCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9241,10 +9251,12 @@ const deserializeAws_restJson1CancelDetectMitigationActionsTaskCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9285,8 +9297,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -9305,10 +9316,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9337,8 +9350,7 @@ const deserializeAws_restJson1CancelJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -9360,10 +9372,12 @@ const deserializeAws_restJson1CancelJobExecutionCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9392,8 +9406,7 @@ const deserializeAws_restJson1ClearDefaultAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9415,10 +9428,12 @@ const deserializeAws_restJson1ClearDefaultAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9447,8 +9462,7 @@ const deserializeAws_restJson1ConfirmTopicRuleDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -9467,10 +9481,12 @@ const deserializeAws_restJson1ConfirmTopicRuleDestinationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9499,8 +9515,7 @@ const deserializeAws_restJson1CreateAuditSuppressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9519,10 +9534,12 @@ const deserializeAws_restJson1CreateAuditSuppressionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9559,8 +9576,7 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9585,10 +9601,12 @@ const deserializeAws_restJson1CreateAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9629,8 +9647,7 @@ const deserializeAws_restJson1CreateBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9646,10 +9663,12 @@ const deserializeAws_restJson1CreateBillingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9690,8 +9709,7 @@ const deserializeAws_restJson1CreateCertificateFromCsrCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9710,10 +9728,12 @@ const deserializeAws_restJson1CreateCertificateFromCsrCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9750,8 +9770,7 @@ const deserializeAws_restJson1CreateCustomMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9770,10 +9789,12 @@ const deserializeAws_restJson1CreateCustomMetricCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9810,8 +9831,7 @@ const deserializeAws_restJson1CreateDimensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9830,10 +9850,12 @@ const deserializeAws_restJson1CreateDimensionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9870,8 +9892,7 @@ const deserializeAws_restJson1CreateDomainConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iot#CertificateValidationException": @@ -9899,10 +9920,12 @@ const deserializeAws_restJson1CreateDomainConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9955,8 +9978,7 @@ const deserializeAws_restJson1CreateDynamicThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -9981,10 +10003,12 @@ const deserializeAws_restJson1CreateDynamicThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10021,8 +10045,7 @@ const deserializeAws_restJson1CreateFleetMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -10059,10 +10082,12 @@ const deserializeAws_restJson1CreateFleetMetricCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10103,8 +10128,7 @@ const deserializeAws_restJson1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -10126,10 +10150,12 @@ const deserializeAws_restJson1CreateJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10166,8 +10192,7 @@ const deserializeAws_restJson1CreateJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iot#ConflictException": @@ -10189,10 +10214,12 @@ const deserializeAws_restJson1CreateJobTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10237,8 +10264,7 @@ const deserializeAws_restJson1CreateKeysAndCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10257,10 +10283,12 @@ const deserializeAws_restJson1CreateKeysAndCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10297,8 +10325,7 @@ const deserializeAws_restJson1CreateMitigationActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10317,10 +10344,12 @@ const deserializeAws_restJson1CreateMitigationActionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10369,8 +10398,7 @@ const deserializeAws_restJson1CreateOTAUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10398,10 +10426,12 @@ const deserializeAws_restJson1CreateOTAUpdateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10446,8 +10476,7 @@ const deserializeAws_restJson1CreatePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10472,10 +10501,12 @@ const deserializeAws_restJson1CreatePolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10520,8 +10551,7 @@ const deserializeAws_restJson1CreatePolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10549,10 +10579,12 @@ const deserializeAws_restJson1CreatePolicyVersionCommandError = async ( throw await deserializeAws_restJson1VersionsLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10597,8 +10629,7 @@ const deserializeAws_restJson1CreateProvisioningClaimCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10620,10 +10651,12 @@ const deserializeAws_restJson1CreateProvisioningClaimCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10664,8 +10697,7 @@ const deserializeAws_restJson1CreateProvisioningTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10687,10 +10719,12 @@ const deserializeAws_restJson1CreateProvisioningTemplateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10735,8 +10769,7 @@ const deserializeAws_restJson1CreateProvisioningTemplateVersionCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -10761,10 +10794,12 @@ const deserializeAws_restJson1CreateProvisioningTemplateVersionCommandError = as throw await deserializeAws_restJson1VersionsLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10801,8 +10836,7 @@ const deserializeAws_restJson1CreateRoleAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10827,10 +10861,12 @@ const deserializeAws_restJson1CreateRoleAliasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10863,8 +10899,7 @@ const deserializeAws_restJson1CreateScheduledAuditCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10883,10 +10918,12 @@ const deserializeAws_restJson1CreateScheduledAuditCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10923,8 +10960,7 @@ const deserializeAws_restJson1CreateSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -10940,10 +10976,12 @@ const deserializeAws_restJson1CreateSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10988,8 +11026,7 @@ const deserializeAws_restJson1CreateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11017,10 +11054,12 @@ const deserializeAws_restJson1CreateStreamCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11061,8 +11100,7 @@ const deserializeAws_restJson1CreateThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11087,10 +11125,12 @@ const deserializeAws_restJson1CreateThingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11131,8 +11171,7 @@ const deserializeAws_restJson1CreateThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11148,10 +11187,12 @@ const deserializeAws_restJson1CreateThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11192,8 +11233,7 @@ const deserializeAws_restJson1CreateThingTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11215,10 +11255,12 @@ const deserializeAws_restJson1CreateThingTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11247,8 +11289,7 @@ const deserializeAws_restJson1CreateTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -11270,10 +11311,12 @@ const deserializeAws_restJson1CreateTopicRuleCommandError = async ( throw await deserializeAws_restJson1SqlParseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11306,8 +11349,7 @@ const deserializeAws_restJson1CreateTopicRuleDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -11326,10 +11368,12 @@ const deserializeAws_restJson1CreateTopicRuleDestinationCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11358,8 +11402,7 @@ const deserializeAws_restJson1DeleteAccountAuditConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11375,10 +11418,12 @@ const deserializeAws_restJson1DeleteAccountAuditConfigurationCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11407,8 +11452,7 @@ const deserializeAws_restJson1DeleteAuditSuppressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11421,10 +11465,12 @@ const deserializeAws_restJson1DeleteAuditSuppressionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11453,8 +11499,7 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iot#DeleteConflictException": @@ -11479,10 +11524,12 @@ const deserializeAws_restJson1DeleteAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11511,8 +11558,7 @@ const deserializeAws_restJson1DeleteBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11528,10 +11574,12 @@ const deserializeAws_restJson1DeleteBillingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11560,8 +11608,7 @@ const deserializeAws_restJson1DeleteCACertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateStateException": case "com.amazonaws.iot#CertificateStateException": @@ -11586,10 +11633,12 @@ const deserializeAws_restJson1DeleteCACertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11618,8 +11667,7 @@ const deserializeAws_restJson1DeleteCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateStateException": case "com.amazonaws.iot#CertificateStateException": @@ -11647,10 +11695,12 @@ const deserializeAws_restJson1DeleteCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11679,8 +11729,7 @@ const deserializeAws_restJson1DeleteCustomMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11693,10 +11742,12 @@ const deserializeAws_restJson1DeleteCustomMetricCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11725,8 +11776,7 @@ const deserializeAws_restJson1DeleteDimensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11739,10 +11789,12 @@ const deserializeAws_restJson1DeleteDimensionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11771,8 +11823,7 @@ const deserializeAws_restJson1DeleteDomainConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11794,10 +11845,12 @@ const deserializeAws_restJson1DeleteDomainConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11826,8 +11879,7 @@ const deserializeAws_restJson1DeleteDynamicThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11843,10 +11895,12 @@ const deserializeAws_restJson1DeleteDynamicThingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11875,8 +11929,7 @@ const deserializeAws_restJson1DeleteFleetMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -11898,10 +11951,12 @@ const deserializeAws_restJson1DeleteFleetMetricCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11930,8 +11985,7 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -11953,10 +12007,12 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11985,8 +12041,7 @@ const deserializeAws_restJson1DeleteJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -12005,10 +12060,12 @@ const deserializeAws_restJson1DeleteJobExecutionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12037,8 +12094,7 @@ const deserializeAws_restJson1DeleteJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12054,10 +12110,12 @@ const deserializeAws_restJson1DeleteJobTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12086,8 +12144,7 @@ const deserializeAws_restJson1DeleteMitigationActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12100,10 +12157,12 @@ const deserializeAws_restJson1DeleteMitigationActionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12132,8 +12191,7 @@ const deserializeAws_restJson1DeleteOTAUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12158,10 +12216,12 @@ const deserializeAws_restJson1DeleteOTAUpdateCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12190,8 +12250,7 @@ const deserializeAws_restJson1DeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iot#DeleteConflictException": @@ -12216,10 +12275,12 @@ const deserializeAws_restJson1DeletePolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12248,8 +12309,7 @@ const deserializeAws_restJson1DeletePolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iot#DeleteConflictException": @@ -12274,10 +12334,12 @@ const deserializeAws_restJson1DeletePolicyVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12306,8 +12368,7 @@ const deserializeAws_restJson1DeleteProvisioningTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -12332,10 +12393,12 @@ const deserializeAws_restJson1DeleteProvisioningTemplateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12364,8 +12427,7 @@ const deserializeAws_restJson1DeleteProvisioningTemplateVersionCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -12390,10 +12452,12 @@ const deserializeAws_restJson1DeleteProvisioningTemplateVersionCommandError = as throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12422,8 +12486,7 @@ const deserializeAws_restJson1DeleteRegistrationCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12442,10 +12505,12 @@ const deserializeAws_restJson1DeleteRegistrationCodeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12474,8 +12539,7 @@ const deserializeAws_restJson1DeleteRoleAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iot#DeleteConflictException": @@ -12500,10 +12564,12 @@ const deserializeAws_restJson1DeleteRoleAliasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12532,8 +12598,7 @@ const deserializeAws_restJson1DeleteScheduledAuditCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12549,10 +12614,12 @@ const deserializeAws_restJson1DeleteScheduledAuditCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12581,8 +12648,7 @@ const deserializeAws_restJson1DeleteSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12598,10 +12664,12 @@ const deserializeAws_restJson1DeleteSecurityProfileCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12630,8 +12698,7 @@ const deserializeAws_restJson1DeleteStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeleteConflictException": case "com.amazonaws.iot#DeleteConflictException": @@ -12656,10 +12723,12 @@ const deserializeAws_restJson1DeleteStreamCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12688,8 +12757,7 @@ const deserializeAws_restJson1DeleteThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12714,10 +12782,12 @@ const deserializeAws_restJson1DeleteThingCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12746,8 +12816,7 @@ const deserializeAws_restJson1DeleteThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12763,10 +12832,12 @@ const deserializeAws_restJson1DeleteThingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12795,8 +12866,7 @@ const deserializeAws_restJson1DeleteThingTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -12818,10 +12888,12 @@ const deserializeAws_restJson1DeleteThingTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12850,8 +12922,7 @@ const deserializeAws_restJson1DeleteTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -12870,10 +12941,12 @@ const deserializeAws_restJson1DeleteTopicRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12902,8 +12975,7 @@ const deserializeAws_restJson1DeleteTopicRuleDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -12922,10 +12994,12 @@ const deserializeAws_restJson1DeleteTopicRuleDestinationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12954,8 +13028,7 @@ const deserializeAws_restJson1DeleteV2LoggingLevelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -12968,10 +13041,12 @@ const deserializeAws_restJson1DeleteV2LoggingLevelCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13000,8 +13075,7 @@ const deserializeAws_restJson1DeprecateThingTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13023,10 +13097,12 @@ const deserializeAws_restJson1DeprecateThingTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13073,8 +13149,7 @@ const deserializeAws_restJson1DescribeAccountAuditConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13084,10 +13159,12 @@ const deserializeAws_restJson1DescribeAccountAuditConfigurationCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13120,8 +13197,7 @@ const deserializeAws_restJson1DescribeAuditFindingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13137,10 +13213,12 @@ const deserializeAws_restJson1DescribeAuditFindingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13203,8 +13281,7 @@ const deserializeAws_restJson1DescribeAuditMitigationActionsTaskCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13220,10 +13297,12 @@ const deserializeAws_restJson1DescribeAuditMitigationActionsTaskCommandError = a throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13272,8 +13351,7 @@ const deserializeAws_restJson1DescribeAuditSuppressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13289,10 +13367,12 @@ const deserializeAws_restJson1DescribeAuditSuppressionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13345,8 +13425,7 @@ const deserializeAws_restJson1DescribeAuditTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13362,10 +13441,12 @@ const deserializeAws_restJson1DescribeAuditTaskCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13398,8 +13479,7 @@ const deserializeAws_restJson1DescribeAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13421,10 +13501,12 @@ const deserializeAws_restJson1DescribeAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13480,8 +13562,7 @@ const deserializeAws_restJson1DescribeBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13497,10 +13578,12 @@ const deserializeAws_restJson1DescribeBillingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13540,8 +13623,7 @@ const deserializeAws_restJson1DescribeCACertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13563,10 +13645,12 @@ const deserializeAws_restJson1DescribeCACertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13602,8 +13686,7 @@ const deserializeAws_restJson1DescribeCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13625,10 +13708,12 @@ const deserializeAws_restJson1DescribeCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13681,8 +13766,7 @@ const deserializeAws_restJson1DescribeCustomMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13698,10 +13782,12 @@ const deserializeAws_restJson1DescribeCustomMetricCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13734,8 +13820,7 @@ const deserializeAws_restJson1DescribeDefaultAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13757,10 +13842,12 @@ const deserializeAws_restJson1DescribeDefaultAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13793,8 +13880,7 @@ const deserializeAws_restJson1DescribeDetectMitigationActionsTaskCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13810,10 +13896,12 @@ const deserializeAws_restJson1DescribeDetectMitigationActionsTaskCommandError = throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13866,8 +13954,7 @@ const deserializeAws_restJson1DescribeDimensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13883,10 +13970,12 @@ const deserializeAws_restJson1DescribeDimensionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13951,8 +14040,7 @@ const deserializeAws_restJson1DescribeDomainConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -13974,10 +14062,12 @@ const deserializeAws_restJson1DescribeDomainConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14010,8 +14100,7 @@ const deserializeAws_restJson1DescribeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14027,10 +14116,12 @@ const deserializeAws_restJson1DescribeEndpointCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14071,8 +14162,7 @@ const deserializeAws_restJson1DescribeEventConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14082,10 +14172,12 @@ const deserializeAws_restJson1DescribeEventConfigurationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14166,8 +14258,7 @@ const deserializeAws_restJson1DescribeFleetMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14189,10 +14280,12 @@ const deserializeAws_restJson1DescribeFleetMetricCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14233,8 +14326,7 @@ const deserializeAws_restJson1DescribeIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14256,10 +14348,12 @@ const deserializeAws_restJson1DescribeIndexCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14296,8 +14390,7 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -14313,10 +14406,12 @@ const deserializeAws_restJson1DescribeJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14349,8 +14444,7 @@ const deserializeAws_restJson1DescribeJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -14366,10 +14460,12 @@ const deserializeAws_restJson1DescribeJobExecutionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14448,8 +14544,7 @@ const deserializeAws_restJson1DescribeJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14465,10 +14560,12 @@ const deserializeAws_restJson1DescribeJobTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14525,8 +14622,7 @@ const deserializeAws_restJson1DescribeManagedJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iot#InternalServerException": @@ -14542,10 +14638,12 @@ const deserializeAws_restJson1DescribeManagedJobTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14606,8 +14704,7 @@ const deserializeAws_restJson1DescribeMitigationActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14623,10 +14720,12 @@ const deserializeAws_restJson1DescribeMitigationActionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14695,8 +14794,7 @@ const deserializeAws_restJson1DescribeProvisioningTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14715,10 +14813,12 @@ const deserializeAws_restJson1DescribeProvisioningTemplateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14763,8 +14863,7 @@ const deserializeAws_restJson1DescribeProvisioningTemplateVersionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14783,10 +14882,12 @@ const deserializeAws_restJson1DescribeProvisioningTemplateVersionCommandError = throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14819,8 +14920,7 @@ const deserializeAws_restJson1DescribeRoleAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14842,10 +14942,12 @@ const deserializeAws_restJson1DescribeRoleAliasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14898,8 +15000,7 @@ const deserializeAws_restJson1DescribeScheduledAuditCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -14915,10 +15016,12 @@ const deserializeAws_restJson1DescribeScheduledAuditCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14993,8 +15096,7 @@ const deserializeAws_restJson1DescribeSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15010,10 +15112,12 @@ const deserializeAws_restJson1DescribeSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15046,8 +15150,7 @@ const deserializeAws_restJson1DescribeStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15069,10 +15172,12 @@ const deserializeAws_restJson1DescribeStreamCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15133,8 +15238,7 @@ const deserializeAws_restJson1DescribeThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15156,10 +15260,12 @@ const deserializeAws_restJson1DescribeThingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15228,8 +15334,7 @@ const deserializeAws_restJson1DescribeThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15245,10 +15350,12 @@ const deserializeAws_restJson1DescribeThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15325,8 +15432,7 @@ const deserializeAws_restJson1DescribeThingRegistrationTaskCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15345,10 +15451,12 @@ const deserializeAws_restJson1DescribeThingRegistrationTaskCommandError = async throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15397,8 +15505,7 @@ const deserializeAws_restJson1DescribeThingTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15420,10 +15527,12 @@ const deserializeAws_restJson1DescribeThingTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15452,8 +15561,7 @@ const deserializeAws_restJson1DetachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15475,10 +15583,12 @@ const deserializeAws_restJson1DetachPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15507,8 +15617,7 @@ const deserializeAws_restJson1DetachPrincipalPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15530,10 +15639,12 @@ const deserializeAws_restJson1DetachPrincipalPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15562,8 +15673,7 @@ const deserializeAws_restJson1DetachSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15579,10 +15689,12 @@ const deserializeAws_restJson1DetachSecurityProfileCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15611,8 +15723,7 @@ const deserializeAws_restJson1DetachThingPrincipalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15634,10 +15745,12 @@ const deserializeAws_restJson1DetachThingPrincipalCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15666,8 +15779,7 @@ const deserializeAws_restJson1DisableTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -15686,10 +15798,12 @@ const deserializeAws_restJson1DisableTopicRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15718,8 +15832,7 @@ const deserializeAws_restJson1EnableTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -15738,10 +15851,12 @@ const deserializeAws_restJson1EnableTopicRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15778,8 +15893,7 @@ const deserializeAws_restJson1GetBehaviorModelTrainingSummariesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15795,10 +15909,12 @@ const deserializeAws_restJson1GetBehaviorModelTrainingSummariesCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15835,8 +15951,7 @@ const deserializeAws_restJson1GetBucketsAggregationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -15867,10 +15982,12 @@ const deserializeAws_restJson1GetBucketsAggregationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15903,8 +16020,7 @@ const deserializeAws_restJson1GetCardinalityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -15935,10 +16051,12 @@ const deserializeAws_restJson1GetCardinalityCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15971,8 +16089,7 @@ const deserializeAws_restJson1GetEffectivePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -15997,10 +16114,12 @@ const deserializeAws_restJson1GetEffectivePoliciesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16043,8 +16162,7 @@ const deserializeAws_restJson1GetIndexingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16063,10 +16181,12 @@ const deserializeAws_restJson1GetIndexingConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16099,8 +16219,7 @@ const deserializeAws_restJson1GetJobDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -16116,10 +16235,12 @@ const deserializeAws_restJson1GetJobDocumentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16156,8 +16277,7 @@ const deserializeAws_restJson1GetLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -16170,10 +16290,12 @@ const deserializeAws_restJson1GetLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16206,8 +16328,7 @@ const deserializeAws_restJson1GetOTAUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16229,10 +16350,12 @@ const deserializeAws_restJson1GetOTAUpdateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16265,8 +16388,7 @@ const deserializeAws_restJson1GetPercentilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -16297,10 +16419,12 @@ const deserializeAws_restJson1GetPercentilesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16357,8 +16481,7 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16380,10 +16503,12 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16444,8 +16569,7 @@ const deserializeAws_restJson1GetPolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16467,10 +16591,12 @@ const deserializeAws_restJson1GetPolicyVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16503,8 +16629,7 @@ const deserializeAws_restJson1GetRegistrationCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16523,10 +16648,12 @@ const deserializeAws_restJson1GetRegistrationCodeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16559,8 +16686,7 @@ const deserializeAws_restJson1GetStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -16591,10 +16717,12 @@ const deserializeAws_restJson1GetStatisticsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16631,8 +16759,7 @@ const deserializeAws_restJson1GetTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -16648,10 +16775,12 @@ const deserializeAws_restJson1GetTopicRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16684,8 +16813,7 @@ const deserializeAws_restJson1GetTopicRuleDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -16701,10 +16829,12 @@ const deserializeAws_restJson1GetTopicRuleDestinationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16745,8 +16875,7 @@ const deserializeAws_restJson1GetV2LoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -16759,10 +16888,12 @@ const deserializeAws_restJson1GetV2LoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16799,8 +16930,7 @@ const deserializeAws_restJson1ListActiveViolationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16816,10 +16946,12 @@ const deserializeAws_restJson1ListActiveViolationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16856,8 +16988,7 @@ const deserializeAws_restJson1ListAttachedPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16882,10 +17013,12 @@ const deserializeAws_restJson1ListAttachedPoliciesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16922,8 +17055,7 @@ const deserializeAws_restJson1ListAuditFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16936,10 +17068,12 @@ const deserializeAws_restJson1ListAuditFindingsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16979,8 +17113,7 @@ const deserializeAws_restJson1ListAuditMitigationActionsExecutionsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -16993,10 +17126,12 @@ const deserializeAws_restJson1ListAuditMitigationActionsExecutionsCommandError = throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17033,8 +17168,7 @@ const deserializeAws_restJson1ListAuditMitigationActionsTasksCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17047,10 +17181,12 @@ const deserializeAws_restJson1ListAuditMitigationActionsTasksCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17087,8 +17223,7 @@ const deserializeAws_restJson1ListAuditSuppressionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17101,10 +17236,12 @@ const deserializeAws_restJson1ListAuditSuppressionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17141,8 +17278,7 @@ const deserializeAws_restJson1ListAuditTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17155,10 +17291,12 @@ const deserializeAws_restJson1ListAuditTasksCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17195,8 +17333,7 @@ const deserializeAws_restJson1ListAuthorizersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17215,10 +17352,12 @@ const deserializeAws_restJson1ListAuthorizersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17255,8 +17394,7 @@ const deserializeAws_restJson1ListBillingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17272,10 +17410,12 @@ const deserializeAws_restJson1ListBillingGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17312,8 +17452,7 @@ const deserializeAws_restJson1ListCACertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17332,10 +17471,12 @@ const deserializeAws_restJson1ListCACertificatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17372,8 +17513,7 @@ const deserializeAws_restJson1ListCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17392,10 +17532,12 @@ const deserializeAws_restJson1ListCertificatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17432,8 +17574,7 @@ const deserializeAws_restJson1ListCertificatesByCACommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17452,10 +17593,12 @@ const deserializeAws_restJson1ListCertificatesByCACommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17492,8 +17635,7 @@ const deserializeAws_restJson1ListCustomMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17506,10 +17648,12 @@ const deserializeAws_restJson1ListCustomMetricsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17549,8 +17693,7 @@ const deserializeAws_restJson1ListDetectMitigationActionsExecutionsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17563,10 +17706,12 @@ const deserializeAws_restJson1ListDetectMitigationActionsExecutionsCommandError throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17603,8 +17748,7 @@ const deserializeAws_restJson1ListDetectMitigationActionsTasksCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17617,10 +17761,12 @@ const deserializeAws_restJson1ListDetectMitigationActionsTasksCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17657,8 +17803,7 @@ const deserializeAws_restJson1ListDimensionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17671,10 +17816,12 @@ const deserializeAws_restJson1ListDimensionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17711,8 +17858,7 @@ const deserializeAws_restJson1ListDomainConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17731,10 +17877,12 @@ const deserializeAws_restJson1ListDomainConfigurationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17771,8 +17919,7 @@ const deserializeAws_restJson1ListFleetMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17791,10 +17938,12 @@ const deserializeAws_restJson1ListFleetMetricsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17831,8 +17980,7 @@ const deserializeAws_restJson1ListIndicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -17851,10 +17999,12 @@ const deserializeAws_restJson1ListIndicesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17894,8 +18044,7 @@ const deserializeAws_restJson1ListJobExecutionsForJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -17911,10 +18060,12 @@ const deserializeAws_restJson1ListJobExecutionsForJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -17954,8 +18105,7 @@ const deserializeAws_restJson1ListJobExecutionsForThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -17971,10 +18121,12 @@ const deserializeAws_restJson1ListJobExecutionsForThingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18011,8 +18163,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -18028,10 +18179,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18068,8 +18221,7 @@ const deserializeAws_restJson1ListJobTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18082,10 +18234,12 @@ const deserializeAws_restJson1ListJobTemplatesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18125,8 +18279,7 @@ const deserializeAws_restJson1ListManagedJobTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iot#InternalServerException": @@ -18142,10 +18295,12 @@ const deserializeAws_restJson1ListManagedJobTemplatesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18182,8 +18337,7 @@ const deserializeAws_restJson1ListMetricValuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18199,10 +18353,12 @@ const deserializeAws_restJson1ListMetricValuesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18242,8 +18398,7 @@ const deserializeAws_restJson1ListMitigationActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18256,10 +18411,12 @@ const deserializeAws_restJson1ListMitigationActionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18296,8 +18453,7 @@ const deserializeAws_restJson1ListOTAUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18316,10 +18472,12 @@ const deserializeAws_restJson1ListOTAUpdatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18356,8 +18514,7 @@ const deserializeAws_restJson1ListOutgoingCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18376,10 +18533,12 @@ const deserializeAws_restJson1ListOutgoingCertificatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18416,8 +18575,7 @@ const deserializeAws_restJson1ListPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18436,10 +18594,12 @@ const deserializeAws_restJson1ListPoliciesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18476,8 +18636,7 @@ const deserializeAws_restJson1ListPolicyPrincipalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18499,10 +18658,12 @@ const deserializeAws_restJson1ListPolicyPrincipalsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18535,8 +18696,7 @@ const deserializeAws_restJson1ListPolicyVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18558,10 +18718,12 @@ const deserializeAws_restJson1ListPolicyVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18598,8 +18760,7 @@ const deserializeAws_restJson1ListPrincipalPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18621,10 +18782,12 @@ const deserializeAws_restJson1ListPrincipalPoliciesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18661,8 +18824,7 @@ const deserializeAws_restJson1ListPrincipalThingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18684,10 +18846,12 @@ const deserializeAws_restJson1ListPrincipalThingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18724,8 +18888,7 @@ const deserializeAws_restJson1ListProvisioningTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18741,10 +18904,12 @@ const deserializeAws_restJson1ListProvisioningTemplatesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18781,8 +18946,7 @@ const deserializeAws_restJson1ListProvisioningTemplateVersionsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18801,10 +18965,12 @@ const deserializeAws_restJson1ListProvisioningTemplateVersionsCommandError = asy throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18841,8 +19007,7 @@ const deserializeAws_restJson1ListRoleAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18861,10 +19026,12 @@ const deserializeAws_restJson1ListRoleAliasesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18901,8 +19068,7 @@ const deserializeAws_restJson1ListScheduledAuditsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18915,10 +19081,12 @@ const deserializeAws_restJson1ListScheduledAuditsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18958,8 +19126,7 @@ const deserializeAws_restJson1ListSecurityProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -18975,10 +19142,12 @@ const deserializeAws_restJson1ListSecurityProfilesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19018,8 +19187,7 @@ const deserializeAws_restJson1ListSecurityProfilesForTargetCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19035,10 +19203,12 @@ const deserializeAws_restJson1ListSecurityProfilesForTargetCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19075,8 +19245,7 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19095,10 +19264,12 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19135,8 +19306,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19152,10 +19322,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19192,8 +19364,7 @@ const deserializeAws_restJson1ListTargetsForPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19218,10 +19389,12 @@ const deserializeAws_restJson1ListTargetsForPolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19261,8 +19434,7 @@ const deserializeAws_restJson1ListTargetsForSecurityProfileCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19278,10 +19450,12 @@ const deserializeAws_restJson1ListTargetsForSecurityProfileCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19318,8 +19492,7 @@ const deserializeAws_restJson1ListThingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19335,10 +19508,12 @@ const deserializeAws_restJson1ListThingGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19375,8 +19550,7 @@ const deserializeAws_restJson1ListThingGroupsForThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19392,10 +19566,12 @@ const deserializeAws_restJson1ListThingGroupsForThingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19432,8 +19608,7 @@ const deserializeAws_restJson1ListThingPrincipalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19455,10 +19630,12 @@ const deserializeAws_restJson1ListThingPrincipalsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19499,8 +19676,7 @@ const deserializeAws_restJson1ListThingRegistrationTaskReportsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19516,10 +19692,12 @@ const deserializeAws_restJson1ListThingRegistrationTaskReportsCommandError = asy throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19556,8 +19734,7 @@ const deserializeAws_restJson1ListThingRegistrationTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19573,10 +19750,12 @@ const deserializeAws_restJson1ListThingRegistrationTasksCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19613,8 +19792,7 @@ const deserializeAws_restJson1ListThingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19633,10 +19811,12 @@ const deserializeAws_restJson1ListThingsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19673,8 +19853,7 @@ const deserializeAws_restJson1ListThingsInBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19690,10 +19869,12 @@ const deserializeAws_restJson1ListThingsInBillingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19730,8 +19911,7 @@ const deserializeAws_restJson1ListThingsInThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19747,10 +19927,12 @@ const deserializeAws_restJson1ListThingsInThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19787,8 +19969,7 @@ const deserializeAws_restJson1ListThingTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -19807,10 +19988,12 @@ const deserializeAws_restJson1ListThingTypesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19850,8 +20033,7 @@ const deserializeAws_restJson1ListTopicRuleDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -19867,10 +20049,12 @@ const deserializeAws_restJson1ListTopicRuleDestinationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19907,8 +20091,7 @@ const deserializeAws_restJson1ListTopicRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -19921,10 +20104,12 @@ const deserializeAws_restJson1ListTopicRulesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -19964,8 +20149,7 @@ const deserializeAws_restJson1ListV2LoggingLevelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -19981,10 +20165,12 @@ const deserializeAws_restJson1ListV2LoggingLevelsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20021,8 +20207,7 @@ const deserializeAws_restJson1ListViolationEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20035,10 +20220,12 @@ const deserializeAws_restJson1ListViolationEventsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20067,8 +20254,7 @@ const deserializeAws_restJson1PutVerificationStateOnViolationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20081,10 +20267,12 @@ const deserializeAws_restJson1PutVerificationStateOnViolationCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20121,8 +20309,7 @@ const deserializeAws_restJson1RegisterCACertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iot#CertificateValidationException": @@ -20153,10 +20340,12 @@ const deserializeAws_restJson1RegisterCACertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20193,8 +20382,7 @@ const deserializeAws_restJson1RegisterCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateConflictException": case "com.amazonaws.iot#CertificateConflictException": @@ -20225,10 +20413,12 @@ const deserializeAws_restJson1RegisterCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20265,8 +20455,7 @@ const deserializeAws_restJson1RegisterCertificateWithoutCACommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateStateException": case "com.amazonaws.iot#CertificateStateException": @@ -20294,10 +20483,12 @@ const deserializeAws_restJson1RegisterCertificateWithoutCACommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20334,8 +20525,7 @@ const deserializeAws_restJson1RegisterThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -20360,10 +20550,12 @@ const deserializeAws_restJson1RegisterThingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20392,8 +20584,7 @@ const deserializeAws_restJson1RejectCertificateTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20418,10 +20609,12 @@ const deserializeAws_restJson1RejectCertificateTransferCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20450,8 +20643,7 @@ const deserializeAws_restJson1RemoveThingFromBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20467,10 +20659,12 @@ const deserializeAws_restJson1RemoveThingFromBillingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20499,8 +20693,7 @@ const deserializeAws_restJson1RemoveThingFromThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20516,10 +20709,12 @@ const deserializeAws_restJson1RemoveThingFromThingGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20548,8 +20743,7 @@ const deserializeAws_restJson1ReplaceTopicRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -20571,10 +20765,12 @@ const deserializeAws_restJson1ReplaceTopicRuleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20615,8 +20811,7 @@ const deserializeAws_restJson1SearchIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -20644,10 +20839,12 @@ const deserializeAws_restJson1SearchIndexCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20684,8 +20881,7 @@ const deserializeAws_restJson1SetDefaultAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20710,10 +20906,12 @@ const deserializeAws_restJson1SetDefaultAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20742,8 +20940,7 @@ const deserializeAws_restJson1SetDefaultPolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20765,10 +20962,12 @@ const deserializeAws_restJson1SetDefaultPolicyVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20797,8 +20996,7 @@ const deserializeAws_restJson1SetLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -20811,10 +21009,12 @@ const deserializeAws_restJson1SetLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20843,8 +21043,7 @@ const deserializeAws_restJson1SetV2LoggingLevelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -20863,10 +21062,12 @@ const deserializeAws_restJson1SetV2LoggingLevelCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20895,8 +21096,7 @@ const deserializeAws_restJson1SetV2LoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.iot#InternalException": @@ -20909,10 +21109,12 @@ const deserializeAws_restJson1SetV2LoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -20945,8 +21147,7 @@ const deserializeAws_restJson1StartAuditMitigationActionsTaskCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -20965,10 +21166,12 @@ const deserializeAws_restJson1StartAuditMitigationActionsTaskCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21001,8 +21204,7 @@ const deserializeAws_restJson1StartDetectMitigationActionsTaskCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21021,10 +21223,12 @@ const deserializeAws_restJson1StartDetectMitigationActionsTaskCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21057,8 +21261,7 @@ const deserializeAws_restJson1StartOnDemandAuditTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21074,10 +21277,12 @@ const deserializeAws_restJson1StartOnDemandAuditTaskCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21110,8 +21315,7 @@ const deserializeAws_restJson1StartThingRegistrationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21127,10 +21331,12 @@ const deserializeAws_restJson1StartThingRegistrationTaskCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21159,8 +21365,7 @@ const deserializeAws_restJson1StopThingRegistrationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21179,10 +21384,12 @@ const deserializeAws_restJson1StopThingRegistrationTaskCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21211,8 +21418,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21231,10 +21437,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21267,8 +21475,7 @@ const deserializeAws_restJson1TestAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21293,10 +21500,12 @@ const deserializeAws_restJson1TestAuthorizationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21345,8 +21554,7 @@ const deserializeAws_restJson1TestInvokeAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21371,10 +21579,12 @@ const deserializeAws_restJson1TestInvokeAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21407,8 +21617,7 @@ const deserializeAws_restJson1TransferCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateStateException": case "com.amazonaws.iot#CertificateStateException": @@ -21436,10 +21645,12 @@ const deserializeAws_restJson1TransferCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21468,8 +21679,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21485,10 +21695,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21517,8 +21729,7 @@ const deserializeAws_restJson1UpdateAccountAuditConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21531,10 +21742,12 @@ const deserializeAws_restJson1UpdateAccountAuditConfigurationCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21563,8 +21776,7 @@ const deserializeAws_restJson1UpdateAuditSuppressionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21580,10 +21792,12 @@ const deserializeAws_restJson1UpdateAuditSuppressionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21620,8 +21834,7 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21646,10 +21859,12 @@ const deserializeAws_restJson1UpdateAuthorizerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21682,8 +21897,7 @@ const deserializeAws_restJson1UpdateBillingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21702,10 +21916,12 @@ const deserializeAws_restJson1UpdateBillingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21734,8 +21950,7 @@ const deserializeAws_restJson1UpdateCACertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21757,10 +21972,12 @@ const deserializeAws_restJson1UpdateCACertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21789,8 +22006,7 @@ const deserializeAws_restJson1UpdateCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateStateException": case "com.amazonaws.iot#CertificateStateException": @@ -21815,10 +22031,12 @@ const deserializeAws_restJson1UpdateCertificateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21871,8 +22089,7 @@ const deserializeAws_restJson1UpdateCustomMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21888,10 +22105,12 @@ const deserializeAws_restJson1UpdateCustomMetricCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21944,8 +22163,7 @@ const deserializeAws_restJson1UpdateDimensionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -21961,10 +22179,12 @@ const deserializeAws_restJson1UpdateDimensionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22001,8 +22221,7 @@ const deserializeAws_restJson1UpdateDomainConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateValidationException": case "com.amazonaws.iot#CertificateValidationException": @@ -22027,10 +22246,12 @@ const deserializeAws_restJson1UpdateDomainConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22063,8 +22284,7 @@ const deserializeAws_restJson1UpdateDynamicThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22086,10 +22306,12 @@ const deserializeAws_restJson1UpdateDynamicThingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22118,8 +22340,7 @@ const deserializeAws_restJson1UpdateEventConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22132,10 +22353,12 @@ const deserializeAws_restJson1UpdateEventConfigurationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22164,8 +22387,7 @@ const deserializeAws_restJson1UpdateFleetMetricCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IndexNotReadyException": case "com.amazonaws.iot#IndexNotReadyException": @@ -22199,10 +22421,12 @@ const deserializeAws_restJson1UpdateFleetMetricCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22231,8 +22455,7 @@ const deserializeAws_restJson1UpdateIndexingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22251,10 +22474,12 @@ const deserializeAws_restJson1UpdateIndexingConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22283,8 +22508,7 @@ const deserializeAws_restJson1UpdateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.iot#InvalidRequestException": @@ -22300,10 +22524,12 @@ const deserializeAws_restJson1UpdateJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22340,8 +22566,7 @@ const deserializeAws_restJson1UpdateMitigationActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22357,10 +22582,12 @@ const deserializeAws_restJson1UpdateMitigationActionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22389,8 +22616,7 @@ const deserializeAws_restJson1UpdateProvisioningTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -22409,10 +22635,12 @@ const deserializeAws_restJson1UpdateProvisioningTemplateCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22449,8 +22677,7 @@ const deserializeAws_restJson1UpdateRoleAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22472,10 +22699,12 @@ const deserializeAws_restJson1UpdateRoleAliasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22508,8 +22737,7 @@ const deserializeAws_restJson1UpdateScheduledAuditCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22525,10 +22753,12 @@ const deserializeAws_restJson1UpdateScheduledAuditCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22603,8 +22833,7 @@ const deserializeAws_restJson1UpdateSecurityProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22623,10 +22852,12 @@ const deserializeAws_restJson1UpdateSecurityProfileCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22671,8 +22902,7 @@ const deserializeAws_restJson1UpdateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22694,10 +22924,12 @@ const deserializeAws_restJson1UpdateStreamCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22726,8 +22958,7 @@ const deserializeAws_restJson1UpdateThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22752,10 +22983,12 @@ const deserializeAws_restJson1UpdateThingCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22788,8 +23021,7 @@ const deserializeAws_restJson1UpdateThingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22808,10 +23040,12 @@ const deserializeAws_restJson1UpdateThingGroupCommandError = async ( throw await deserializeAws_restJson1VersionConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22840,8 +23074,7 @@ const deserializeAws_restJson1UpdateThingGroupsForThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22857,10 +23090,12 @@ const deserializeAws_restJson1UpdateThingGroupsForThingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22889,8 +23124,7 @@ const deserializeAws_restJson1UpdateTopicRuleDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingResourceUpdateException": case "com.amazonaws.iot#ConflictingResourceUpdateException": @@ -22909,10 +23143,12 @@ const deserializeAws_restJson1UpdateTopicRuleDestinationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -22949,8 +23185,7 @@ const deserializeAws_restJson1ValidateSecurityProfileBehaviorsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iot#InternalFailureException": @@ -22963,10 +23198,12 @@ const deserializeAws_restJson1ValidateSecurityProfileBehaviorsCommandError = asy throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -29347,7 +29584,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -29373,6 +29610,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotanalytics/src/protocols/Aws_restJson1.ts b/clients/client-iotanalytics/src/protocols/Aws_restJson1.ts index 004ff431dfa80..694a44ef2fa7d 100644 --- a/clients/client-iotanalytics/src/protocols/Aws_restJson1.ts +++ b/clients/client-iotanalytics/src/protocols/Aws_restJson1.ts @@ -1292,8 +1292,7 @@ const deserializeAws_restJson1BatchPutMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1312,10 +1311,12 @@ const deserializeAws_restJson1BatchPutMessageCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1344,8 +1345,7 @@ const deserializeAws_restJson1CancelPipelineReprocessingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1364,10 +1364,12 @@ const deserializeAws_restJson1CancelPipelineReprocessingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1408,8 +1410,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1431,10 +1432,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1475,8 +1478,7 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1498,10 +1500,12 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1534,8 +1538,7 @@ const deserializeAws_restJson1CreateDatasetContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1554,10 +1557,12 @@ const deserializeAws_restJson1CreateDatasetContentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1598,8 +1603,7 @@ const deserializeAws_restJson1CreateDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1621,10 +1625,12 @@ const deserializeAws_restJson1CreateDatastoreCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1661,8 +1667,7 @@ const deserializeAws_restJson1CreatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1684,10 +1689,12 @@ const deserializeAws_restJson1CreatePipelineCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1716,8 +1723,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1736,10 +1742,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1776,7 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1788,10 +1795,12 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1820,8 +1829,7 @@ const deserializeAws_restJson1DeleteDatasetContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1840,10 +1848,12 @@ const deserializeAws_restJson1DeleteDatasetContentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1872,8 +1882,7 @@ const deserializeAws_restJson1DeleteDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1892,10 +1901,12 @@ const deserializeAws_restJson1DeleteDatastoreCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1924,8 +1935,7 @@ const deserializeAws_restJson1DeletePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -1944,10 +1954,12 @@ const deserializeAws_restJson1DeletePipelineCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1984,8 +1996,7 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2004,10 +2015,12 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2040,8 +2053,7 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2060,10 +2072,12 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2100,8 +2114,7 @@ const deserializeAws_restJson1DescribeDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2120,10 +2133,12 @@ const deserializeAws_restJson1DescribeDatastoreCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2156,8 +2171,7 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2176,10 +2190,12 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2212,8 +2228,7 @@ const deserializeAws_restJson1DescribePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2232,10 +2247,12 @@ const deserializeAws_restJson1DescribePipelineCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2276,8 +2293,7 @@ const deserializeAws_restJson1GetDatasetContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2296,10 +2312,12 @@ const deserializeAws_restJson1GetDatasetContentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2336,8 +2354,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2353,10 +2370,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2396,8 +2415,7 @@ const deserializeAws_restJson1ListDatasetContentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2416,10 +2434,12 @@ const deserializeAws_restJson1ListDatasetContentsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2456,8 +2476,7 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2473,10 +2492,12 @@ const deserializeAws_restJson1ListDatasetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2513,8 +2534,7 @@ const deserializeAws_restJson1ListDatastoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2530,10 +2550,12 @@ const deserializeAws_restJson1ListDatastoresCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2570,8 +2592,7 @@ const deserializeAws_restJson1ListPipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2587,10 +2608,12 @@ const deserializeAws_restJson1ListPipelinesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2623,8 +2646,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2646,10 +2668,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2678,8 +2702,7 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2695,10 +2718,12 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2735,8 +2760,7 @@ const deserializeAws_restJson1RunPipelineActivityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2752,10 +2776,12 @@ const deserializeAws_restJson1RunPipelineActivityCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2788,8 +2814,7 @@ const deserializeAws_restJson1SampleChannelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2808,10 +2833,12 @@ const deserializeAws_restJson1SampleChannelDataCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2844,8 +2871,7 @@ const deserializeAws_restJson1StartPipelineReprocessingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2867,10 +2893,12 @@ const deserializeAws_restJson1StartPipelineReprocessingCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2899,8 +2927,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2922,10 +2949,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2954,8 +2983,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -2977,10 +3005,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3009,8 +3039,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -3029,10 +3058,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3061,8 +3092,7 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -3081,10 +3111,12 @@ const deserializeAws_restJson1UpdateDatasetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3113,8 +3145,7 @@ const deserializeAws_restJson1UpdateDatastoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -3133,10 +3164,12 @@ const deserializeAws_restJson1UpdateDatastoreCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3165,8 +3198,7 @@ const deserializeAws_restJson1UpdatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotanalytics#InternalFailureException": @@ -3188,10 +3220,12 @@ const deserializeAws_restJson1UpdatePipelineCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5344,7 +5378,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5370,6 +5404,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotdeviceadvisor/src/protocols/Aws_restJson1.ts b/clients/client-iotdeviceadvisor/src/protocols/Aws_restJson1.ts index e052abab837fd..14a5464e11c9f 100644 --- a/clients/client-iotdeviceadvisor/src/protocols/Aws_restJson1.ts +++ b/clients/client-iotdeviceadvisor/src/protocols/Aws_restJson1.ts @@ -559,8 +559,7 @@ const deserializeAws_restJson1CreateSuiteDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -570,10 +569,12 @@ const deserializeAws_restJson1CreateSuiteDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -602,8 +603,7 @@ const deserializeAws_restJson1DeleteSuiteDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -613,10 +613,12 @@ const deserializeAws_restJson1DeleteSuiteDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -649,8 +651,7 @@ const deserializeAws_restJson1GetEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -663,10 +664,12 @@ const deserializeAws_restJson1GetEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -730,8 +733,7 @@ const deserializeAws_restJson1GetSuiteDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -744,10 +746,12 @@ const deserializeAws_restJson1GetSuiteDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -820,8 +824,7 @@ const deserializeAws_restJson1GetSuiteRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -834,10 +837,12 @@ const deserializeAws_restJson1GetSuiteRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -870,8 +875,7 @@ const deserializeAws_restJson1GetSuiteRunReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -884,10 +888,12 @@ const deserializeAws_restJson1GetSuiteRunReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -927,8 +933,7 @@ const deserializeAws_restJson1ListSuiteDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -938,10 +943,12 @@ const deserializeAws_restJson1ListSuiteDefinitionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -978,8 +985,7 @@ const deserializeAws_restJson1ListSuiteRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -989,10 +995,12 @@ const deserializeAws_restJson1ListSuiteRunsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1025,8 +1033,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -1039,10 +1046,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1083,8 +1092,7 @@ const deserializeAws_restJson1StartSuiteRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotdeviceadvisor#ConflictException": @@ -1097,10 +1105,12 @@ const deserializeAws_restJson1StartSuiteRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1129,8 +1139,7 @@ const deserializeAws_restJson1StopSuiteRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -1143,10 +1152,12 @@ const deserializeAws_restJson1StopSuiteRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1175,8 +1186,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -1189,10 +1199,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1221,8 +1233,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -1235,10 +1246,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1291,8 +1304,7 @@ const deserializeAws_restJson1UpdateSuiteDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iotdeviceadvisor#InternalServerException": @@ -1302,10 +1314,12 @@ const deserializeAws_restJson1UpdateSuiteDefinitionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1692,7 +1706,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1718,6 +1732,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotfleethub/src/protocols/Aws_restJson1.ts b/clients/client-iotfleethub/src/protocols/Aws_restJson1.ts index 2ac9dec79746b..694b9f8c1ca87 100644 --- a/clients/client-iotfleethub/src/protocols/Aws_restJson1.ts +++ b/clients/client-iotfleethub/src/protocols/Aws_restJson1.ts @@ -317,8 +317,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -334,10 +333,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -366,8 +367,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -383,10 +383,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -463,8 +465,7 @@ const deserializeAws_restJson1DescribeApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -480,10 +481,12 @@ const deserializeAws_restJson1DescribeApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -520,8 +523,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -534,10 +536,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -570,8 +574,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -584,10 +587,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -616,8 +621,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -630,10 +634,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -662,8 +668,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotfleethub#InternalFailureException": @@ -676,10 +681,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -708,8 +715,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.iotfleethub#ConflictException": @@ -728,10 +734,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -918,7 +926,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -944,6 +952,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotsecuretunneling/src/protocols/Aws_json1_1.ts b/clients/client-iotsecuretunneling/src/protocols/Aws_json1_1.ts index 65459ecacfc48..9df6b134f8da3 100644 --- a/clients/client-iotsecuretunneling/src/protocols/Aws_json1_1.ts +++ b/clients/client-iotsecuretunneling/src/protocols/Aws_json1_1.ts @@ -187,18 +187,19 @@ const deserializeAws_json1_1CloseTunnelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -230,18 +231,19 @@ const deserializeAws_json1_1DescribeTunnelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -273,18 +275,19 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -316,15 +319,16 @@ const deserializeAws_json1_1ListTunnelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -356,18 +360,19 @@ const deserializeAws_json1_1OpenTunnelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.iotsecuretunneling#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -399,18 +404,19 @@ const deserializeAws_json1_1RotateTunnelAccessTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -442,18 +448,19 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -485,18 +492,19 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -913,7 +921,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -939,6 +947,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotsitewise/src/protocols/Aws_restJson1.ts b/clients/client-iotsitewise/src/protocols/Aws_restJson1.ts index 7af90ac802992..5957d558ec978 100644 --- a/clients/client-iotsitewise/src/protocols/Aws_restJson1.ts +++ b/clients/client-iotsitewise/src/protocols/Aws_restJson1.ts @@ -2934,8 +2934,7 @@ const deserializeAws_restJson1AssociateAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -2957,10 +2956,12 @@ const deserializeAws_restJson1AssociateAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2989,8 +2990,7 @@ const deserializeAws_restJson1AssociateTimeSeriesToAssetPropertyCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -3009,10 +3009,12 @@ const deserializeAws_restJson1AssociateTimeSeriesToAssetPropertyCommandError = a throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3045,8 +3047,7 @@ const deserializeAws_restJson1BatchAssociateProjectAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3065,10 +3066,12 @@ const deserializeAws_restJson1BatchAssociateProjectAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3101,8 +3104,7 @@ const deserializeAws_restJson1BatchDisassociateProjectAssetsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3118,10 +3120,12 @@ const deserializeAws_restJson1BatchDisassociateProjectAssetsCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3175,8 +3179,7 @@ const deserializeAws_restJson1BatchGetAssetPropertyAggregatesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3192,10 +3195,12 @@ const deserializeAws_restJson1BatchGetAssetPropertyAggregatesCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3246,8 +3251,7 @@ const deserializeAws_restJson1BatchGetAssetPropertyValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3263,10 +3267,12 @@ const deserializeAws_restJson1BatchGetAssetPropertyValueCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3320,8 +3326,7 @@ const deserializeAws_restJson1BatchGetAssetPropertyValueHistoryCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3337,10 +3342,12 @@ const deserializeAws_restJson1BatchGetAssetPropertyValueHistoryCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3373,8 +3380,7 @@ const deserializeAws_restJson1BatchPutAssetPropertyValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -3399,10 +3405,12 @@ const deserializeAws_restJson1BatchPutAssetPropertyValueCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3439,8 +3447,7 @@ const deserializeAws_restJson1CreateAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3459,10 +3466,12 @@ const deserializeAws_restJson1CreateAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3503,8 +3512,7 @@ const deserializeAws_restJson1CreateAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -3529,10 +3537,12 @@ const deserializeAws_restJson1CreateAssetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3573,8 +3583,7 @@ const deserializeAws_restJson1CreateAssetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -3599,10 +3608,12 @@ const deserializeAws_restJson1CreateAssetModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3639,8 +3650,7 @@ const deserializeAws_restJson1CreateDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3659,10 +3669,12 @@ const deserializeAws_restJson1CreateDashboardCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3699,8 +3711,7 @@ const deserializeAws_restJson1CreateGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3719,10 +3730,12 @@ const deserializeAws_restJson1CreateGatewayCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3771,8 +3784,7 @@ const deserializeAws_restJson1CreatePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3791,10 +3803,12 @@ const deserializeAws_restJson1CreatePortalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3831,8 +3845,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3851,10 +3864,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3883,8 +3898,7 @@ const deserializeAws_restJson1DeleteAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -3900,10 +3914,12 @@ const deserializeAws_restJson1DeleteAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3936,8 +3952,7 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -3956,10 +3971,12 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3992,8 +4009,7 @@ const deserializeAws_restJson1DeleteAssetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -4012,10 +4028,12 @@ const deserializeAws_restJson1DeleteAssetModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4044,8 +4062,7 @@ const deserializeAws_restJson1DeleteDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4061,10 +4078,12 @@ const deserializeAws_restJson1DeleteDashboardCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4093,8 +4112,7 @@ const deserializeAws_restJson1DeleteGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4110,10 +4128,12 @@ const deserializeAws_restJson1DeleteGatewayCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4146,8 +4166,7 @@ const deserializeAws_restJson1DeletePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -4166,10 +4185,12 @@ const deserializeAws_restJson1DeletePortalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4198,8 +4219,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4215,10 +4235,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4247,8 +4269,7 @@ const deserializeAws_restJson1DeleteTimeSeriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -4267,10 +4288,12 @@ const deserializeAws_restJson1DeleteTimeSeriesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4331,8 +4354,7 @@ const deserializeAws_restJson1DescribeAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4348,10 +4370,12 @@ const deserializeAws_restJson1DescribeAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4424,8 +4448,7 @@ const deserializeAws_restJson1DescribeAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4441,10 +4464,12 @@ const deserializeAws_restJson1DescribeAssetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4520,8 +4545,7 @@ const deserializeAws_restJson1DescribeAssetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4537,10 +4561,12 @@ const deserializeAws_restJson1DescribeAssetModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4589,8 +4615,7 @@ const deserializeAws_restJson1DescribeAssetPropertyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4606,10 +4631,12 @@ const deserializeAws_restJson1DescribeAssetPropertyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4672,8 +4699,7 @@ const deserializeAws_restJson1DescribeDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4689,10 +4715,12 @@ const deserializeAws_restJson1DescribeDashboardCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4733,8 +4761,7 @@ const deserializeAws_restJson1DescribeDefaultEncryptionConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4747,10 +4774,12 @@ const deserializeAws_restJson1DescribeDefaultEncryptionConfigurationCommandError throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4810,8 +4839,7 @@ const deserializeAws_restJson1DescribeGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4827,10 +4855,12 @@ const deserializeAws_restJson1DescribeGatewayCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4875,8 +4905,7 @@ const deserializeAws_restJson1DescribeGatewayCapabilityConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4892,10 +4921,12 @@ const deserializeAws_restJson1DescribeGatewayCapabilityConfigurationCommandError throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4928,8 +4959,7 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -4945,10 +4975,12 @@ const deserializeAws_restJson1DescribeLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5037,8 +5069,7 @@ const deserializeAws_restJson1DescribePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5054,10 +5085,12 @@ const deserializeAws_restJson1DescribePortalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5114,8 +5147,7 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5131,10 +5163,12 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5187,8 +5221,7 @@ const deserializeAws_restJson1DescribeStorageConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -5210,10 +5243,12 @@ const deserializeAws_restJson1DescribeStorageConfigurationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5278,8 +5313,7 @@ const deserializeAws_restJson1DescribeTimeSeriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5295,10 +5329,12 @@ const deserializeAws_restJson1DescribeTimeSeriesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5327,8 +5363,7 @@ const deserializeAws_restJson1DisassociateAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -5347,10 +5382,12 @@ const deserializeAws_restJson1DisassociateAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5379,8 +5416,7 @@ const deserializeAws_restJson1DisassociateTimeSeriesFromAssetPropertyCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -5399,10 +5435,12 @@ const deserializeAws_restJson1DisassociateTimeSeriesFromAssetPropertyCommandErro throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5439,8 +5477,7 @@ const deserializeAws_restJson1GetAssetPropertyAggregatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5459,10 +5496,12 @@ const deserializeAws_restJson1GetAssetPropertyAggregatesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5495,8 +5534,7 @@ const deserializeAws_restJson1GetAssetPropertyValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5515,10 +5553,12 @@ const deserializeAws_restJson1GetAssetPropertyValueCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5558,8 +5598,7 @@ const deserializeAws_restJson1GetAssetPropertyValueHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5578,10 +5617,12 @@ const deserializeAws_restJson1GetAssetPropertyValueHistoryCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5621,8 +5662,7 @@ const deserializeAws_restJson1GetInterpolatedAssetPropertyValuesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5641,10 +5681,12 @@ const deserializeAws_restJson1GetInterpolatedAssetPropertyValuesCommandError = a throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5681,8 +5723,7 @@ const deserializeAws_restJson1ListAccessPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5695,10 +5736,12 @@ const deserializeAws_restJson1ListAccessPoliciesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5735,8 +5778,7 @@ const deserializeAws_restJson1ListAssetModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5749,10 +5791,12 @@ const deserializeAws_restJson1ListAssetModelsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5792,8 +5836,7 @@ const deserializeAws_restJson1ListAssetRelationshipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5809,10 +5852,12 @@ const deserializeAws_restJson1ListAssetRelationshipsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5849,8 +5894,7 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5866,10 +5910,12 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5906,8 +5952,7 @@ const deserializeAws_restJson1ListAssociatedAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5923,10 +5968,12 @@ const deserializeAws_restJson1ListAssociatedAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5963,8 +6010,7 @@ const deserializeAws_restJson1ListDashboardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -5977,10 +6023,12 @@ const deserializeAws_restJson1ListDashboardsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6017,8 +6065,7 @@ const deserializeAws_restJson1ListGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6031,10 +6078,12 @@ const deserializeAws_restJson1ListGatewaysCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6071,8 +6120,7 @@ const deserializeAws_restJson1ListPortalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6085,10 +6133,12 @@ const deserializeAws_restJson1ListPortalsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6125,8 +6175,7 @@ const deserializeAws_restJson1ListProjectAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6139,10 +6188,12 @@ const deserializeAws_restJson1ListProjectAssetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6179,8 +6230,7 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6193,10 +6243,12 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6229,8 +6281,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6255,10 +6306,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6295,8 +6348,7 @@ const deserializeAws_restJson1ListTimeSeriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6312,10 +6364,12 @@ const deserializeAws_restJson1ListTimeSeriesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6356,8 +6410,7 @@ const deserializeAws_restJson1PutDefaultEncryptionConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6376,10 +6429,12 @@ const deserializeAws_restJson1PutDefaultEncryptionConfigurationCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6408,8 +6463,7 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6428,10 +6482,12 @@ const deserializeAws_restJson1PutLoggingOptionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6480,8 +6536,7 @@ const deserializeAws_restJson1PutStorageConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6506,10 +6561,12 @@ const deserializeAws_restJson1PutStorageConfigurationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6538,8 +6595,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6567,10 +6623,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6599,8 +6657,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6625,10 +6682,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6657,8 +6716,7 @@ const deserializeAws_restJson1UpdateAccessPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6674,10 +6732,12 @@ const deserializeAws_restJson1UpdateAccessPolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6710,8 +6770,7 @@ const deserializeAws_restJson1UpdateAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6733,10 +6792,12 @@ const deserializeAws_restJson1UpdateAssetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6769,8 +6830,7 @@ const deserializeAws_restJson1UpdateAssetModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6795,10 +6855,12 @@ const deserializeAws_restJson1UpdateAssetModelCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6827,8 +6889,7 @@ const deserializeAws_restJson1UpdateAssetPropertyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6847,10 +6908,12 @@ const deserializeAws_restJson1UpdateAssetPropertyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6879,8 +6942,7 @@ const deserializeAws_restJson1UpdateDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -6896,10 +6958,12 @@ const deserializeAws_restJson1UpdateDashboardCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6928,8 +6992,7 @@ const deserializeAws_restJson1UpdateGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -6948,10 +7011,12 @@ const deserializeAws_restJson1UpdateGatewayCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6988,8 +7053,7 @@ const deserializeAws_restJson1UpdateGatewayCapabilityConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -7011,10 +7075,12 @@ const deserializeAws_restJson1UpdateGatewayCapabilityConfigurationCommandError = throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7047,8 +7113,7 @@ const deserializeAws_restJson1UpdatePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.iotsitewise#ConflictingOperationException": @@ -7067,10 +7132,12 @@ const deserializeAws_restJson1UpdatePortalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7099,8 +7166,7 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotsitewise#InternalFailureException": @@ -7116,10 +7182,12 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9436,7 +9504,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9462,6 +9530,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iotthingsgraph/src/protocols/Aws_json1_1.ts b/clients/client-iotthingsgraph/src/protocols/Aws_json1_1.ts index df9cb97738baf..fd1f14fc8436a 100644 --- a/clients/client-iotthingsgraph/src/protocols/Aws_json1_1.ts +++ b/clients/client-iotthingsgraph/src/protocols/Aws_json1_1.ts @@ -695,8 +695,7 @@ const deserializeAws_json1_1AssociateEntityToThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -712,10 +711,12 @@ const deserializeAws_json1_1AssociateEntityToThingCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -747,8 +748,7 @@ const deserializeAws_json1_1CreateFlowTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -767,10 +767,12 @@ const deserializeAws_json1_1CreateFlowTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -802,8 +804,7 @@ const deserializeAws_json1_1CreateSystemInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -822,10 +823,12 @@ const deserializeAws_json1_1CreateSystemInstanceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -857,8 +860,7 @@ const deserializeAws_json1_1CreateSystemTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -874,10 +876,12 @@ const deserializeAws_json1_1CreateSystemTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -909,8 +913,7 @@ const deserializeAws_json1_1DeleteFlowTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -926,10 +929,12 @@ const deserializeAws_json1_1DeleteFlowTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -961,8 +966,7 @@ const deserializeAws_json1_1DeleteNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -972,10 +976,12 @@ const deserializeAws_json1_1DeleteNamespaceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1007,8 +1013,7 @@ const deserializeAws_json1_1DeleteSystemInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1024,10 +1029,12 @@ const deserializeAws_json1_1DeleteSystemInstanceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1059,8 +1066,7 @@ const deserializeAws_json1_1DeleteSystemTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1076,10 +1082,12 @@ const deserializeAws_json1_1DeleteSystemTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1111,8 +1119,7 @@ const deserializeAws_json1_1DeploySystemInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1131,10 +1138,12 @@ const deserializeAws_json1_1DeploySystemInstanceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1166,8 +1175,7 @@ const deserializeAws_json1_1DeprecateFlowTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1183,10 +1191,12 @@ const deserializeAws_json1_1DeprecateFlowTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1218,8 +1228,7 @@ const deserializeAws_json1_1DeprecateSystemTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1235,10 +1244,12 @@ const deserializeAws_json1_1DeprecateSystemTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1270,8 +1281,7 @@ const deserializeAws_json1_1DescribeNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1287,10 +1297,12 @@ const deserializeAws_json1_1DescribeNamespaceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1334,7 @@ const deserializeAws_json1_1DissociateEntityFromThingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1339,10 +1350,12 @@ const deserializeAws_json1_1DissociateEntityFromThingCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1374,8 +1387,7 @@ const deserializeAws_json1_1GetEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1391,10 +1403,12 @@ const deserializeAws_json1_1GetEntitiesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1426,8 +1440,7 @@ const deserializeAws_json1_1GetFlowTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1443,10 +1456,12 @@ const deserializeAws_json1_1GetFlowTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1493,7 @@ const deserializeAws_json1_1GetFlowTemplateRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1495,10 +1509,12 @@ const deserializeAws_json1_1GetFlowTemplateRevisionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1530,8 +1546,7 @@ const deserializeAws_json1_1GetNamespaceDeletionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1544,10 +1559,12 @@ const deserializeAws_json1_1GetNamespaceDeletionStatusCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1579,8 +1596,7 @@ const deserializeAws_json1_1GetSystemInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1596,10 +1612,12 @@ const deserializeAws_json1_1GetSystemInstanceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1649,7 @@ const deserializeAws_json1_1GetSystemTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1648,10 +1665,12 @@ const deserializeAws_json1_1GetSystemTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1683,8 +1702,7 @@ const deserializeAws_json1_1GetSystemTemplateRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1700,10 +1718,12 @@ const deserializeAws_json1_1GetSystemTemplateRevisionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1735,8 +1755,7 @@ const deserializeAws_json1_1GetUploadStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1752,10 +1771,12 @@ const deserializeAws_json1_1GetUploadStatusCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1787,8 +1808,7 @@ const deserializeAws_json1_1ListFlowExecutionMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1804,10 +1824,12 @@ const deserializeAws_json1_1ListFlowExecutionMessagesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1839,8 +1861,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1856,10 +1877,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1891,8 +1914,7 @@ const deserializeAws_json1_1SearchEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1905,10 +1927,12 @@ const deserializeAws_json1_1SearchEntitiesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1940,8 +1964,7 @@ const deserializeAws_json1_1SearchFlowExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -1957,10 +1980,12 @@ const deserializeAws_json1_1SearchFlowExecutionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1992,8 +2017,7 @@ const deserializeAws_json1_1SearchFlowTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2006,10 +2030,12 @@ const deserializeAws_json1_1SearchFlowTemplatesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2041,8 +2067,7 @@ const deserializeAws_json1_1SearchSystemInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2055,10 +2080,12 @@ const deserializeAws_json1_1SearchSystemInstancesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2090,8 +2117,7 @@ const deserializeAws_json1_1SearchSystemTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2104,10 +2130,12 @@ const deserializeAws_json1_1SearchSystemTemplatesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2139,8 +2167,7 @@ const deserializeAws_json1_1SearchThingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2156,10 +2183,12 @@ const deserializeAws_json1_1SearchThingsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2191,8 +2220,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2208,10 +2236,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2243,8 +2273,7 @@ const deserializeAws_json1_1UndeploySystemInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2263,10 +2292,12 @@ const deserializeAws_json1_1UndeploySystemInstanceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2298,8 +2329,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2315,10 +2345,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2350,8 +2382,7 @@ const deserializeAws_json1_1UpdateFlowTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2367,10 +2398,12 @@ const deserializeAws_json1_1UpdateFlowTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2402,8 +2435,7 @@ const deserializeAws_json1_1UpdateSystemTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2419,10 +2451,12 @@ const deserializeAws_json1_1UpdateSystemTemplateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2454,8 +2488,7 @@ const deserializeAws_json1_1UploadEntityDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.iotthingsgraph#InternalFailureException": @@ -2468,10 +2501,12 @@ const deserializeAws_json1_1UploadEntityDefinitionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3921,7 +3956,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3947,6 +3982,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-iottwinmaker/src/protocols/Aws_restJson1.ts b/clients/client-iottwinmaker/src/protocols/Aws_restJson1.ts index 5516193147507..41bdbb587d32c 100644 --- a/clients/client-iottwinmaker/src/protocols/Aws_restJson1.ts +++ b/clients/client-iottwinmaker/src/protocols/Aws_restJson1.ts @@ -1334,8 +1334,7 @@ const deserializeAws_restJson1BatchPutPropertyValuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -1351,10 +1350,12 @@ const deserializeAws_restJson1BatchPutPropertyValuesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1395,8 +1396,7 @@ const deserializeAws_restJson1CreateComponentTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1418,10 +1418,12 @@ const deserializeAws_restJson1CreateComponentTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1466,8 +1468,7 @@ const deserializeAws_restJson1CreateEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1489,10 +1490,12 @@ const deserializeAws_restJson1CreateEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1529,8 +1532,7 @@ const deserializeAws_restJson1CreateSceneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1552,10 +1554,12 @@ const deserializeAws_restJson1CreateSceneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1592,8 +1596,7 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1615,10 +1618,12 @@ const deserializeAws_restJson1CreateWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1656,7 @@ const deserializeAws_restJson1DeleteComponentTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1671,10 +1675,12 @@ const deserializeAws_restJson1DeleteComponentTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1707,8 +1713,7 @@ const deserializeAws_restJson1DeleteEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -1727,10 +1732,12 @@ const deserializeAws_restJson1DeleteEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1759,8 +1766,7 @@ const deserializeAws_restJson1DeleteSceneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1779,10 +1785,12 @@ const deserializeAws_restJson1DeleteSceneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1811,8 +1819,7 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1831,10 +1838,12 @@ const deserializeAws_restJson1DeleteWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1918,8 +1927,7 @@ const deserializeAws_restJson1GetComponentTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -1935,10 +1943,12 @@ const deserializeAws_restJson1GetComponentTypeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2011,8 +2021,7 @@ const deserializeAws_restJson1GetEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -2031,10 +2040,12 @@ const deserializeAws_restJson1GetEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2078,7 @@ const deserializeAws_restJson1GetPropertyValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2093,10 +2103,12 @@ const deserializeAws_restJson1GetPropertyValueCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2145,7 @@ const deserializeAws_restJson1GetPropertyValueHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2159,10 +2170,12 @@ const deserializeAws_restJson1GetPropertyValueHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2223,8 +2236,7 @@ const deserializeAws_restJson1GetSceneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2243,10 +2255,12 @@ const deserializeAws_restJson1GetSceneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2303,8 +2317,7 @@ const deserializeAws_restJson1GetWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -2323,10 +2336,12 @@ const deserializeAws_restJson1GetWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2374,8 +2389,7 @@ const deserializeAws_restJson1ListComponentTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2391,10 +2405,12 @@ const deserializeAws_restJson1ListComponentTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2431,8 +2447,7 @@ const deserializeAws_restJson1ListEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -2448,10 +2463,12 @@ const deserializeAws_restJson1ListEntitiesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2488,8 +2505,7 @@ const deserializeAws_restJson1ListScenesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2505,10 +2521,12 @@ const deserializeAws_restJson1ListScenesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2545,8 +2563,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2556,10 +2573,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2596,8 +2615,7 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.iottwinmaker#InternalServerException": @@ -2613,10 +2631,12 @@ const deserializeAws_restJson1ListWorkspacesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2645,8 +2665,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2659,10 +2678,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2691,8 +2712,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2702,10 +2722,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2750,8 +2772,7 @@ const deserializeAws_restJson1UpdateComponentTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2773,10 +2794,12 @@ const deserializeAws_restJson1UpdateComponentTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2813,8 +2836,7 @@ const deserializeAws_restJson1UpdateEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2839,10 +2861,12 @@ const deserializeAws_restJson1UpdateEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2875,8 +2899,7 @@ const deserializeAws_restJson1UpdateSceneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2895,10 +2918,12 @@ const deserializeAws_restJson1UpdateSceneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2931,8 +2956,7 @@ const deserializeAws_restJson1UpdateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.iottwinmaker#AccessDeniedException": @@ -2954,10 +2978,12 @@ const deserializeAws_restJson1UpdateWorkspaceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4238,7 +4264,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4264,6 +4290,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ivs/src/protocols/Aws_restJson1.ts b/clients/client-ivs/src/protocols/Aws_restJson1.ts index 2e8009d51c4ae..3e19512e39038 100644 --- a/clients/client-ivs/src/protocols/Aws_restJson1.ts +++ b/clients/client-ivs/src/protocols/Aws_restJson1.ts @@ -878,15 +878,16 @@ const deserializeAws_restJson1BatchGetChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -923,15 +924,16 @@ const deserializeAws_restJson1BatchGetStreamKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -968,8 +970,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -988,10 +989,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1027,8 +1030,7 @@ const deserializeAws_restJson1CreateRecordingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1050,10 +1052,12 @@ const deserializeAws_restJson1CreateRecordingConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1086,8 +1090,7 @@ const deserializeAws_restJson1CreateStreamKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1106,10 +1109,12 @@ const deserializeAws_restJson1CreateStreamKeyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1138,8 +1143,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1158,10 +1162,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1190,8 +1196,7 @@ const deserializeAws_restJson1DeletePlaybackKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1207,10 +1212,12 @@ const deserializeAws_restJson1DeletePlaybackKeyPairCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1239,8 +1246,7 @@ const deserializeAws_restJson1DeleteRecordingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1259,10 +1265,12 @@ const deserializeAws_restJson1DeleteRecordingConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1291,8 +1299,7 @@ const deserializeAws_restJson1DeleteStreamKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1308,10 +1315,12 @@ const deserializeAws_restJson1DeleteStreamKeyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1344,8 +1353,7 @@ const deserializeAws_restJson1GetChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1358,10 +1366,12 @@ const deserializeAws_restJson1GetChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1394,8 +1404,7 @@ const deserializeAws_restJson1GetPlaybackKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1408,10 +1417,12 @@ const deserializeAws_restJson1GetPlaybackKeyPairCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1447,8 +1458,7 @@ const deserializeAws_restJson1GetRecordingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1464,10 +1474,12 @@ const deserializeAws_restJson1GetRecordingConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1500,8 +1512,7 @@ const deserializeAws_restJson1GetStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1517,10 +1528,12 @@ const deserializeAws_restJson1GetStreamCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1553,8 +1566,7 @@ const deserializeAws_restJson1GetStreamKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1567,10 +1579,12 @@ const deserializeAws_restJson1GetStreamKeyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1617,7 @@ const deserializeAws_restJson1GetStreamSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1617,10 +1630,12 @@ const deserializeAws_restJson1GetStreamSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1653,8 +1668,7 @@ const deserializeAws_restJson1ImportPlaybackKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1673,10 +1687,12 @@ const deserializeAws_restJson1ImportPlaybackKeyPairCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1713,8 +1729,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1727,10 +1742,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1767,8 +1784,7 @@ const deserializeAws_restJson1ListPlaybackKeyPairsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1778,10 +1794,12 @@ const deserializeAws_restJson1ListPlaybackKeyPairsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1821,8 +1839,7 @@ const deserializeAws_restJson1ListRecordingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1835,10 +1852,12 @@ const deserializeAws_restJson1ListRecordingConfigurationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1875,8 +1894,7 @@ const deserializeAws_restJson1ListStreamKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1889,10 +1907,12 @@ const deserializeAws_restJson1ListStreamKeysCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1929,8 +1949,7 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1940,10 +1959,12 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1980,8 +2001,7 @@ const deserializeAws_restJson1ListStreamSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -1994,10 +2014,12 @@ const deserializeAws_restJson1ListStreamSessionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2030,8 +2052,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivs#InternalServerException": @@ -2044,10 +2065,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2076,8 +2099,7 @@ const deserializeAws_restJson1PutMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -2096,10 +2118,12 @@ const deserializeAws_restJson1PutMetadataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2128,8 +2152,7 @@ const deserializeAws_restJson1StopStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -2148,10 +2171,12 @@ const deserializeAws_restJson1StopStreamCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2180,8 +2205,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivs#InternalServerException": @@ -2194,10 +2218,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2226,8 +2252,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivs#InternalServerException": @@ -2240,10 +2265,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2276,8 +2303,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivs#AccessDeniedException": @@ -2296,10 +2322,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2988,7 +3016,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3014,6 +3042,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ivschat/src/protocols/Aws_restJson1.ts b/clients/client-ivschat/src/protocols/Aws_restJson1.ts index b4f7fdf991b19..5c5f13b28c167 100644 --- a/clients/client-ivschat/src/protocols/Aws_restJson1.ts +++ b/clients/client-ivschat/src/protocols/Aws_restJson1.ts @@ -434,8 +434,7 @@ const deserializeAws_restJson1CreateChatTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -451,10 +450,12 @@ const deserializeAws_restJson1CreateChatTokenCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -519,8 +520,7 @@ const deserializeAws_restJson1CreateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -542,10 +542,12 @@ const deserializeAws_restJson1CreateRoomCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -578,8 +580,7 @@ const deserializeAws_restJson1DeleteMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -595,10 +596,12 @@ const deserializeAws_restJson1DeleteMessageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -627,8 +630,7 @@ const deserializeAws_restJson1DeleteRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -644,10 +646,12 @@ const deserializeAws_restJson1DeleteRoomCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -676,8 +680,7 @@ const deserializeAws_restJson1DisconnectUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -693,10 +696,12 @@ const deserializeAws_restJson1DisconnectUserCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -761,8 +766,7 @@ const deserializeAws_restJson1GetRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -775,10 +779,12 @@ const deserializeAws_restJson1GetRoomCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -815,8 +821,7 @@ const deserializeAws_restJson1ListRoomsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -829,10 +834,12 @@ const deserializeAws_restJson1ListRoomsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -865,8 +872,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivschat#InternalServerException": @@ -879,10 +885,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -915,8 +923,7 @@ const deserializeAws_restJson1SendEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -932,10 +939,12 @@ const deserializeAws_restJson1SendEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -964,8 +973,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivschat#InternalServerException": @@ -978,10 +986,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1010,8 +1020,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ivschat#InternalServerException": @@ -1024,10 +1033,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1092,8 +1103,7 @@ const deserializeAws_restJson1UpdateRoomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ivschat#AccessDeniedException": @@ -1109,10 +1119,12 @@ const deserializeAws_restJson1UpdateRoomCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1457,7 +1469,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1483,6 +1495,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kafka/src/protocols/Aws_restJson1.ts b/clients/client-kafka/src/protocols/Aws_restJson1.ts index e517146dd5245..c333afb4c5569 100644 --- a/clients/client-kafka/src/protocols/Aws_restJson1.ts +++ b/clients/client-kafka/src/protocols/Aws_restJson1.ts @@ -1380,8 +1380,7 @@ const deserializeAws_restJson1BatchAssociateScramSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1406,10 +1405,12 @@ const deserializeAws_restJson1BatchAssociateScramSecretCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1449,8 +1450,7 @@ const deserializeAws_restJson1BatchDisassociateScramSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1475,10 +1475,12 @@ const deserializeAws_restJson1BatchDisassociateScramSecretCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1519,8 +1521,7 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1545,10 +1546,12 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1593,8 +1596,7 @@ const deserializeAws_restJson1CreateClusterV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1619,10 +1621,12 @@ const deserializeAws_restJson1CreateClusterV2CommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1671,8 +1675,7 @@ const deserializeAws_restJson1CreateConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1697,10 +1700,12 @@ const deserializeAws_restJson1CreateConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1737,8 +1742,7 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1754,10 +1758,12 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1794,8 +1800,7 @@ const deserializeAws_restJson1DeleteConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1811,10 +1816,12 @@ const deserializeAws_restJson1DeleteConfigurationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1847,8 +1854,7 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1867,10 +1873,12 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1903,8 +1911,7 @@ const deserializeAws_restJson1DescribeClusterOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1923,10 +1930,12 @@ const deserializeAws_restJson1DescribeClusterOperationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1959,8 +1968,7 @@ const deserializeAws_restJson1DescribeClusterV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -1979,10 +1987,12 @@ const deserializeAws_restJson1DescribeClusterV2CommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2039,8 +2049,7 @@ const deserializeAws_restJson1DescribeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2062,10 +2071,12 @@ const deserializeAws_restJson1DescribeConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2114,8 +2125,7 @@ const deserializeAws_restJson1DescribeConfigurationRevisionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2137,10 +2147,12 @@ const deserializeAws_restJson1DescribeConfigurationRevisionCommandError = async throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2197,8 +2209,7 @@ const deserializeAws_restJson1GetBootstrapBrokersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2217,10 +2228,12 @@ const deserializeAws_restJson1GetBootstrapBrokersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2256,8 +2269,7 @@ const deserializeAws_restJson1GetCompatibleKafkaVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2282,10 +2294,12 @@ const deserializeAws_restJson1GetCompatibleKafkaVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2325,8 +2339,7 @@ const deserializeAws_restJson1ListClusterOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2342,10 +2355,12 @@ const deserializeAws_restJson1ListClusterOperationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2382,8 +2397,7 @@ const deserializeAws_restJson1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2399,10 +2413,12 @@ const deserializeAws_restJson1ListClustersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2439,8 +2455,7 @@ const deserializeAws_restJson1ListClustersV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2456,10 +2471,12 @@ const deserializeAws_restJson1ListClustersV2CommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2496,8 +2513,7 @@ const deserializeAws_restJson1ListConfigurationRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2519,10 +2535,12 @@ const deserializeAws_restJson1ListConfigurationRevisionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2577,7 @@ const deserializeAws_restJson1ListConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2579,10 +2596,12 @@ const deserializeAws_restJson1ListConfigurationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2619,8 +2638,7 @@ const deserializeAws_restJson1ListKafkaVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2636,10 +2654,12 @@ const deserializeAws_restJson1ListKafkaVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2676,8 +2696,7 @@ const deserializeAws_restJson1ListNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2693,10 +2712,12 @@ const deserializeAws_restJson1ListNodesCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2733,8 +2754,7 @@ const deserializeAws_restJson1ListScramSecretsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2759,10 +2779,12 @@ const deserializeAws_restJson1ListScramSecretsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2795,8 +2817,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2809,10 +2830,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2849,8 +2872,7 @@ const deserializeAws_restJson1RebootBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2875,10 +2897,12 @@ const deserializeAws_restJson1RebootBrokerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2907,8 +2931,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2921,10 +2944,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2978,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -2967,10 +2991,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3007,8 +3033,7 @@ const deserializeAws_restJson1UpdateBrokerCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3027,10 +3052,12 @@ const deserializeAws_restJson1UpdateBrokerCountCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3067,8 +3094,7 @@ const deserializeAws_restJson1UpdateBrokerStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3087,10 +3113,12 @@ const deserializeAws_restJson1UpdateBrokerStorageCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3127,8 +3155,7 @@ const deserializeAws_restJson1UpdateBrokerTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3153,10 +3180,12 @@ const deserializeAws_restJson1UpdateBrokerTypeCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3193,8 +3222,7 @@ const deserializeAws_restJson1UpdateClusterConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3216,10 +3244,12 @@ const deserializeAws_restJson1UpdateClusterConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3256,8 +3286,7 @@ const deserializeAws_restJson1UpdateClusterKafkaVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3282,10 +3311,12 @@ const deserializeAws_restJson1UpdateClusterKafkaVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3322,8 +3353,7 @@ const deserializeAws_restJson1UpdateConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3345,10 +3375,12 @@ const deserializeAws_restJson1UpdateConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3385,8 +3417,7 @@ const deserializeAws_restJson1UpdateConnectivityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3408,10 +3439,12 @@ const deserializeAws_restJson1UpdateConnectivityCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3448,8 +3481,7 @@ const deserializeAws_restJson1UpdateMonitoringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3468,10 +3500,12 @@ const deserializeAws_restJson1UpdateMonitoringCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3508,8 +3542,7 @@ const deserializeAws_restJson1UpdateSecurityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafka#BadRequestException": @@ -3534,10 +3567,12 @@ const deserializeAws_restJson1UpdateSecurityCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4918,7 +4953,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4944,6 +4979,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kafkaconnect/src/protocols/Aws_restJson1.ts b/clients/client-kafkaconnect/src/protocols/Aws_restJson1.ts index fc98f767ef582..7e0557bd0b463 100644 --- a/clients/client-kafkaconnect/src/protocols/Aws_restJson1.ts +++ b/clients/client-kafkaconnect/src/protocols/Aws_restJson1.ts @@ -520,8 +520,7 @@ const deserializeAws_restJson1CreateConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -549,10 +548,12 @@ const deserializeAws_restJson1CreateConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -597,8 +598,7 @@ const deserializeAws_restJson1CreateCustomPluginCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -626,10 +626,12 @@ const deserializeAws_restJson1CreateCustomPluginCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -674,8 +676,7 @@ const deserializeAws_restJson1CreateWorkerConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -703,10 +704,12 @@ const deserializeAws_restJson1CreateWorkerConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -743,8 +746,7 @@ const deserializeAws_restJson1DeleteConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -769,10 +771,12 @@ const deserializeAws_restJson1DeleteConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -809,8 +813,7 @@ const deserializeAws_restJson1DeleteCustomPluginCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -835,10 +838,12 @@ const deserializeAws_restJson1DeleteCustomPluginCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -944,8 +949,7 @@ const deserializeAws_restJson1DescribeConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -970,10 +974,12 @@ const deserializeAws_restJson1DescribeConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1030,8 +1036,7 @@ const deserializeAws_restJson1DescribeCustomPluginCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1056,10 +1061,12 @@ const deserializeAws_restJson1DescribeCustomPluginCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1111,8 +1118,7 @@ const deserializeAws_restJson1DescribeWorkerConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1137,10 +1143,12 @@ const deserializeAws_restJson1DescribeWorkerConfigurationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1177,8 +1185,7 @@ const deserializeAws_restJson1ListConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1203,10 +1210,12 @@ const deserializeAws_restJson1ListConnectorsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1252,7 @@ const deserializeAws_restJson1ListCustomPluginsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1269,10 +1277,12 @@ const deserializeAws_restJson1ListCustomPluginsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1312,8 +1322,7 @@ const deserializeAws_restJson1ListWorkerConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1338,10 +1347,12 @@ const deserializeAws_restJson1ListWorkerConfigurationsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1378,8 +1389,7 @@ const deserializeAws_restJson1UpdateConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.kafkaconnect#BadRequestException": @@ -1404,10 +1414,12 @@ const deserializeAws_restJson1UpdateConnectorCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2314,7 +2326,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2340,6 +2352,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kendra/src/protocols/Aws_json1_1.ts b/clients/client-kendra/src/protocols/Aws_json1_1.ts index 655401841e37c..9969bc824e2ef 100644 --- a/clients/client-kendra/src/protocols/Aws_json1_1.ts +++ b/clients/client-kendra/src/protocols/Aws_json1_1.ts @@ -1130,8 +1130,7 @@ const deserializeAws_json1_1AssociateEntitiesToExperienceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1153,10 +1152,12 @@ const deserializeAws_json1_1AssociateEntitiesToExperienceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1188,8 +1189,7 @@ const deserializeAws_json1_1AssociatePersonasToEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1211,10 +1211,12 @@ const deserializeAws_json1_1AssociatePersonasToEntitiesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1246,8 +1248,7 @@ const deserializeAws_json1_1BatchDeleteDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1269,10 +1270,12 @@ const deserializeAws_json1_1BatchDeleteDocumentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,8 +1307,7 @@ const deserializeAws_json1_1BatchGetDocumentStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1327,10 +1329,12 @@ const deserializeAws_json1_1BatchGetDocumentStatusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1362,8 +1366,7 @@ const deserializeAws_json1_1BatchPutDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1388,10 +1391,12 @@ const deserializeAws_json1_1BatchPutDocumentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1420,8 +1425,7 @@ const deserializeAws_json1_1ClearQuerySuggestionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1443,10 +1447,12 @@ const deserializeAws_json1_1ClearQuerySuggestionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1484,7 @@ const deserializeAws_json1_1CreateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1507,10 +1512,12 @@ const deserializeAws_json1_1CreateDataSourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1542,8 +1549,7 @@ const deserializeAws_json1_1CreateExperienceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1568,10 +1574,12 @@ const deserializeAws_json1_1CreateExperienceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1611,7 @@ const deserializeAws_json1_1CreateFaqCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1629,10 +1636,12 @@ const deserializeAws_json1_1CreateFaqCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1664,8 +1673,7 @@ const deserializeAws_json1_1CreateIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1690,10 +1698,12 @@ const deserializeAws_json1_1CreateIndexCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1725,8 +1735,7 @@ const deserializeAws_json1_1CreateQuerySuggestionsBlockListCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1751,10 +1760,12 @@ const deserializeAws_json1_1CreateQuerySuggestionsBlockListCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1786,8 +1797,7 @@ const deserializeAws_json1_1CreateThesaurusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1812,10 +1822,12 @@ const deserializeAws_json1_1CreateThesaurusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1844,8 +1856,7 @@ const deserializeAws_json1_1DeleteDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1867,10 +1878,12 @@ const deserializeAws_json1_1DeleteDataSourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1902,8 +1915,7 @@ const deserializeAws_json1_1DeleteExperienceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1925,10 +1937,12 @@ const deserializeAws_json1_1DeleteExperienceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1957,8 +1971,7 @@ const deserializeAws_json1_1DeleteFaqCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -1980,10 +1993,12 @@ const deserializeAws_json1_1DeleteFaqCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2012,8 +2027,7 @@ const deserializeAws_json1_1DeleteIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2035,10 +2049,12 @@ const deserializeAws_json1_1DeleteIndexCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2083,7 @@ const deserializeAws_json1_1DeletePrincipalMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2090,10 +2105,12 @@ const deserializeAws_json1_1DeletePrincipalMappingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2122,8 +2139,7 @@ const deserializeAws_json1_1DeleteQuerySuggestionsBlockListCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2145,10 +2161,12 @@ const deserializeAws_json1_1DeleteQuerySuggestionsBlockListCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2177,8 +2195,7 @@ const deserializeAws_json1_1DeleteThesaurusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2200,10 +2217,12 @@ const deserializeAws_json1_1DeleteThesaurusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2235,8 +2254,7 @@ const deserializeAws_json1_1DescribeDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2255,10 +2273,12 @@ const deserializeAws_json1_1DescribeDataSourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2290,8 +2310,7 @@ const deserializeAws_json1_1DescribeExperienceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2310,10 +2329,12 @@ const deserializeAws_json1_1DescribeExperienceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2345,8 +2366,7 @@ const deserializeAws_json1_1DescribeFaqCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2365,10 +2385,12 @@ const deserializeAws_json1_1DescribeFaqCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2400,8 +2422,7 @@ const deserializeAws_json1_1DescribeIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2420,10 +2441,12 @@ const deserializeAws_json1_1DescribeIndexCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2455,8 +2478,7 @@ const deserializeAws_json1_1DescribePrincipalMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2475,10 +2497,12 @@ const deserializeAws_json1_1DescribePrincipalMappingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2510,8 +2534,7 @@ const deserializeAws_json1_1DescribeQuerySuggestionsBlockListCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2530,10 +2553,12 @@ const deserializeAws_json1_1DescribeQuerySuggestionsBlockListCommandError = asyn throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2565,8 +2590,7 @@ const deserializeAws_json1_1DescribeQuerySuggestionsConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2585,10 +2609,12 @@ const deserializeAws_json1_1DescribeQuerySuggestionsConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2620,8 +2646,7 @@ const deserializeAws_json1_1DescribeThesaurusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2640,10 +2665,12 @@ const deserializeAws_json1_1DescribeThesaurusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2675,8 +2702,7 @@ const deserializeAws_json1_1DisassociateEntitiesFromExperienceCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2695,10 +2721,12 @@ const deserializeAws_json1_1DisassociateEntitiesFromExperienceCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2730,8 +2758,7 @@ const deserializeAws_json1_1DisassociatePersonasFromEntitiesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2750,10 +2777,12 @@ const deserializeAws_json1_1DisassociatePersonasFromEntitiesCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2785,8 +2814,7 @@ const deserializeAws_json1_1GetQuerySuggestionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2811,10 +2839,12 @@ const deserializeAws_json1_1GetQuerySuggestionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2846,8 +2876,7 @@ const deserializeAws_json1_1GetSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2863,10 +2892,12 @@ const deserializeAws_json1_1GetSnapshotsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2898,8 +2929,7 @@ const deserializeAws_json1_1ListDataSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2918,10 +2948,12 @@ const deserializeAws_json1_1ListDataSourcesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2985,7 @@ const deserializeAws_json1_1ListDataSourceSyncJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -2976,10 +3007,12 @@ const deserializeAws_json1_1ListDataSourceSyncJobsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3011,8 +3044,7 @@ const deserializeAws_json1_1ListEntityPersonasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3031,10 +3063,12 @@ const deserializeAws_json1_1ListEntityPersonasCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3066,8 +3100,7 @@ const deserializeAws_json1_1ListExperienceEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3086,10 +3119,12 @@ const deserializeAws_json1_1ListExperienceEntitiesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3121,8 +3156,7 @@ const deserializeAws_json1_1ListExperiencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3141,10 +3175,12 @@ const deserializeAws_json1_1ListExperiencesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3176,8 +3212,7 @@ const deserializeAws_json1_1ListFaqsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3196,10 +3231,12 @@ const deserializeAws_json1_1ListFaqsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3231,8 +3268,7 @@ const deserializeAws_json1_1ListGroupsOlderThanOrderingIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3254,10 +3290,12 @@ const deserializeAws_json1_1ListGroupsOlderThanOrderingIdCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3289,8 +3327,7 @@ const deserializeAws_json1_1ListIndicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3306,10 +3343,12 @@ const deserializeAws_json1_1ListIndicesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3341,8 +3380,7 @@ const deserializeAws_json1_1ListQuerySuggestionsBlockListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3361,10 +3399,12 @@ const deserializeAws_json1_1ListQuerySuggestionsBlockListsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3396,8 +3436,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3416,10 +3455,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3451,8 +3492,7 @@ const deserializeAws_json1_1ListThesauriCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3471,10 +3511,12 @@ const deserializeAws_json1_1ListThesauriCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3503,8 +3545,7 @@ const deserializeAws_json1_1PutPrincipalMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3529,10 +3570,12 @@ const deserializeAws_json1_1PutPrincipalMappingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3564,8 +3607,7 @@ const deserializeAws_json1_1QueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3590,10 +3632,12 @@ const deserializeAws_json1_1QueryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3625,8 +3669,7 @@ const deserializeAws_json1_1StartDataSourceSyncJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3651,10 +3694,12 @@ const deserializeAws_json1_1StartDataSourceSyncJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3683,8 +3728,7 @@ const deserializeAws_json1_1StopDataSourceSyncJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3703,10 +3747,12 @@ const deserializeAws_json1_1StopDataSourceSyncJobCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3735,8 +3781,7 @@ const deserializeAws_json1_1SubmitFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3758,10 +3803,12 @@ const deserializeAws_json1_1SubmitFeedbackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3793,8 +3840,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3813,10 +3859,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3848,8 +3896,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3868,10 +3915,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3900,8 +3949,7 @@ const deserializeAws_json1_1UpdateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3923,10 +3971,12 @@ const deserializeAws_json1_1UpdateDataSourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3955,8 +4005,7 @@ const deserializeAws_json1_1UpdateExperienceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -3978,10 +4027,12 @@ const deserializeAws_json1_1UpdateExperienceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4010,8 +4061,7 @@ const deserializeAws_json1_1UpdateIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -4036,10 +4086,12 @@ const deserializeAws_json1_1UpdateIndexCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4068,8 +4120,7 @@ const deserializeAws_json1_1UpdateQuerySuggestionsBlockListCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -4091,10 +4142,12 @@ const deserializeAws_json1_1UpdateQuerySuggestionsBlockListCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4123,8 +4176,7 @@ const deserializeAws_json1_1UpdateQuerySuggestionsConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -4146,10 +4198,12 @@ const deserializeAws_json1_1UpdateQuerySuggestionsConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4178,8 +4232,7 @@ const deserializeAws_json1_1UpdateThesaurusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kendra#AccessDeniedException": @@ -4201,10 +4254,12 @@ const deserializeAws_json1_1UpdateThesaurusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11087,7 +11142,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -11113,6 +11168,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-keyspaces/src/protocols/Aws_json1_0.ts b/clients/client-keyspaces/src/protocols/Aws_json1_0.ts index 27b1008f1623c..22b5ad9be23b2 100644 --- a/clients/client-keyspaces/src/protocols/Aws_json1_0.ts +++ b/clients/client-keyspaces/src/protocols/Aws_json1_0.ts @@ -278,8 +278,7 @@ const deserializeAws_json1_0CreateKeyspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -298,10 +297,12 @@ const deserializeAws_json1_0CreateKeyspaceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -333,8 +334,7 @@ const deserializeAws_json1_0CreateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -356,10 +356,12 @@ const deserializeAws_json1_0CreateTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -391,8 +393,7 @@ const deserializeAws_json1_0DeleteKeyspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -414,10 +415,12 @@ const deserializeAws_json1_0DeleteKeyspaceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -449,8 +452,7 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -472,10 +474,12 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -507,8 +511,7 @@ const deserializeAws_json1_0GetKeyspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -527,10 +530,12 @@ const deserializeAws_json1_0GetKeyspaceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -562,8 +567,7 @@ const deserializeAws_json1_0GetTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -582,10 +586,12 @@ const deserializeAws_json1_0GetTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -617,8 +623,7 @@ const deserializeAws_json1_0ListKeyspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -637,10 +642,12 @@ const deserializeAws_json1_0ListKeyspacesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -672,8 +679,7 @@ const deserializeAws_json1_0ListTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -692,10 +698,12 @@ const deserializeAws_json1_0ListTablesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -727,8 +735,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -747,10 +754,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -782,8 +791,7 @@ const deserializeAws_json1_0RestoreTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -805,10 +813,12 @@ const deserializeAws_json1_0RestoreTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -840,8 +850,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -860,10 +869,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -895,8 +906,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -918,10 +928,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -953,8 +965,7 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.keyspaces#AccessDeniedException": @@ -976,10 +987,12 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1793,7 +1806,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1819,6 +1832,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-analytics-v2/src/protocols/Aws_json1_1.ts b/clients/client-kinesis-analytics-v2/src/protocols/Aws_json1_1.ts index fcbdf3aaaf4b4..0e47c99771335 100644 --- a/clients/client-kinesis-analytics-v2/src/protocols/Aws_json1_1.ts +++ b/clients/client-kinesis-analytics-v2/src/protocols/Aws_json1_1.ts @@ -744,8 +744,7 @@ const deserializeAws_json1_1AddApplicationCloudWatchLoggingOptionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -767,10 +766,12 @@ const deserializeAws_json1_1AddApplicationCloudWatchLoggingOptionCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -802,8 +803,7 @@ const deserializeAws_json1_1AddApplicationInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalyticsv2#CodeValidationException": @@ -825,10 +825,12 @@ const deserializeAws_json1_1AddApplicationInputCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -860,8 +862,7 @@ const deserializeAws_json1_1AddApplicationInputProcessingConfigurationCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -880,10 +881,12 @@ const deserializeAws_json1_1AddApplicationInputProcessingConfigurationCommandErr throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -915,8 +918,7 @@ const deserializeAws_json1_1AddApplicationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -935,10 +937,12 @@ const deserializeAws_json1_1AddApplicationOutputCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -970,8 +974,7 @@ const deserializeAws_json1_1AddApplicationReferenceDataSourceCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -990,10 +993,12 @@ const deserializeAws_json1_1AddApplicationReferenceDataSourceCommandError = asyn throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1025,8 +1030,7 @@ const deserializeAws_json1_1AddApplicationVpcConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1045,10 +1049,12 @@ const deserializeAws_json1_1AddApplicationVpcConfigurationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1080,8 +1086,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalyticsv2#CodeValidationException": @@ -1109,10 +1114,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1144,8 +1151,7 @@ const deserializeAws_json1_1CreateApplicationPresignedUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1158,10 +1164,12 @@ const deserializeAws_json1_1CreateApplicationPresignedUrlCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1193,8 +1201,7 @@ const deserializeAws_json1_1CreateApplicationSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidApplicationConfigurationException": case "com.amazonaws.kinesisanalyticsv2#InvalidApplicationConfigurationException": @@ -1219,10 +1226,12 @@ const deserializeAws_json1_1CreateApplicationSnapshotCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,8 +1263,7 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1277,10 +1285,12 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1312,8 +1322,7 @@ const deserializeAws_json1_1DeleteApplicationCloudWatchLoggingOptionCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1335,10 +1344,12 @@ const deserializeAws_json1_1DeleteApplicationCloudWatchLoggingOptionCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1370,8 +1381,7 @@ const deserializeAws_json1_1DeleteApplicationInputProcessingConfigurationCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1390,10 +1400,12 @@ const deserializeAws_json1_1DeleteApplicationInputProcessingConfigurationCommand throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1425,8 +1437,7 @@ const deserializeAws_json1_1DeleteApplicationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1445,10 +1456,12 @@ const deserializeAws_json1_1DeleteApplicationOutputCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1480,8 +1493,7 @@ const deserializeAws_json1_1DeleteApplicationReferenceDataSourceCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1500,10 +1512,12 @@ const deserializeAws_json1_1DeleteApplicationReferenceDataSourceCommandError = a throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1535,8 +1549,7 @@ const deserializeAws_json1_1DeleteApplicationSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1555,10 +1568,12 @@ const deserializeAws_json1_1DeleteApplicationSnapshotCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1590,8 +1605,7 @@ const deserializeAws_json1_1DeleteApplicationVpcConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -1610,10 +1624,12 @@ const deserializeAws_json1_1DeleteApplicationVpcConfigurationCommandError = asyn throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1645,8 +1661,7 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1659,10 +1674,12 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1711,7 @@ const deserializeAws_json1_1DescribeApplicationSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1708,10 +1724,12 @@ const deserializeAws_json1_1DescribeApplicationSnapshotCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1743,8 +1761,7 @@ const deserializeAws_json1_1DescribeApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1757,10 +1774,12 @@ const deserializeAws_json1_1DescribeApplicationVersionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1792,8 +1811,7 @@ const deserializeAws_json1_1DiscoverInputSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1815,10 +1833,12 @@ const deserializeAws_json1_1DiscoverInputSchemaCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1850,18 +1870,19 @@ const deserializeAws_json1_1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.kinesisanalyticsv2#InvalidRequestException": throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1893,8 +1914,7 @@ const deserializeAws_json1_1ListApplicationSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1904,10 +1924,12 @@ const deserializeAws_json1_1ListApplicationSnapshotsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1939,8 +1961,7 @@ const deserializeAws_json1_1ListApplicationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalyticsv2#InvalidArgumentException": @@ -1953,10 +1974,12 @@ const deserializeAws_json1_1ListApplicationVersionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1988,8 +2011,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2002,10 +2024,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2037,8 +2061,7 @@ const deserializeAws_json1_1RollbackApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2060,10 +2083,12 @@ const deserializeAws_json1_1RollbackApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2095,8 +2120,7 @@ const deserializeAws_json1_1StartApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidApplicationConfigurationException": case "com.amazonaws.kinesisanalyticsv2#InvalidApplicationConfigurationException": @@ -2115,10 +2139,12 @@ const deserializeAws_json1_1StartApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2150,8 +2176,7 @@ const deserializeAws_json1_1StopApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2173,10 +2198,12 @@ const deserializeAws_json1_1StopApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2208,8 +2235,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2228,10 +2254,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2263,8 +2291,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2283,10 +2310,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2318,8 +2347,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalyticsv2#CodeValidationException": @@ -2347,10 +2375,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2382,8 +2412,7 @@ const deserializeAws_json1_1UpdateApplicationMaintenanceConfigurationCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalyticsv2#ConcurrentModificationException": @@ -2402,10 +2431,12 @@ const deserializeAws_json1_1UpdateApplicationMaintenanceConfigurationCommandErro throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5896,7 +5927,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5922,6 +5953,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-analytics/src/protocols/Aws_json1_1.ts b/clients/client-kinesis-analytics/src/protocols/Aws_json1_1.ts index 256406b276d0e..c427da675815f 100644 --- a/clients/client-kinesis-analytics/src/protocols/Aws_json1_1.ts +++ b/clients/client-kinesis-analytics/src/protocols/Aws_json1_1.ts @@ -468,8 +468,7 @@ const deserializeAws_json1_1AddApplicationCloudWatchLoggingOptionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -488,10 +487,12 @@ const deserializeAws_json1_1AddApplicationCloudWatchLoggingOptionCommandError = throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -523,8 +524,7 @@ const deserializeAws_json1_1AddApplicationInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalytics#CodeValidationException": @@ -546,10 +546,12 @@ const deserializeAws_json1_1AddApplicationInputCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -581,8 +583,7 @@ const deserializeAws_json1_1AddApplicationInputProcessingConfigurationCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -601,10 +602,12 @@ const deserializeAws_json1_1AddApplicationInputProcessingConfigurationCommandErr throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -636,8 +639,7 @@ const deserializeAws_json1_1AddApplicationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -656,10 +658,12 @@ const deserializeAws_json1_1AddApplicationOutputCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -691,8 +695,7 @@ const deserializeAws_json1_1AddApplicationReferenceDataSourceCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -711,10 +714,12 @@ const deserializeAws_json1_1AddApplicationReferenceDataSourceCommandError = asyn throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -746,8 +751,7 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalytics#CodeValidationException": @@ -769,10 +773,12 @@ const deserializeAws_json1_1CreateApplicationCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -804,8 +810,7 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -821,10 +826,12 @@ const deserializeAws_json1_1DeleteApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -856,8 +863,7 @@ const deserializeAws_json1_1DeleteApplicationCloudWatchLoggingOptionCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -876,10 +882,12 @@ const deserializeAws_json1_1DeleteApplicationCloudWatchLoggingOptionCommandError throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +919,7 @@ const deserializeAws_json1_1DeleteApplicationInputProcessingConfigurationCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -931,10 +938,12 @@ const deserializeAws_json1_1DeleteApplicationInputProcessingConfigurationCommand throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -966,8 +975,7 @@ const deserializeAws_json1_1DeleteApplicationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -986,10 +994,12 @@ const deserializeAws_json1_1DeleteApplicationOutputCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1021,8 +1031,7 @@ const deserializeAws_json1_1DeleteApplicationReferenceDataSourceCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -1041,10 +1050,12 @@ const deserializeAws_json1_1DeleteApplicationReferenceDataSourceCommandError = a throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1076,8 +1087,7 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.kinesisanalytics#ResourceNotFoundException": @@ -1087,10 +1097,12 @@ const deserializeAws_json1_1DescribeApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1122,8 +1134,7 @@ const deserializeAws_json1_1DiscoverInputSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesisanalytics#InvalidArgumentException": @@ -1139,10 +1150,12 @@ const deserializeAws_json1_1DiscoverInputSchemaCommandError = async ( throw await deserializeAws_json1_1UnableToDetectSchemaExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1174,15 +1187,16 @@ const deserializeAws_json1_1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1214,8 +1228,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -1228,10 +1241,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1263,8 +1278,7 @@ const deserializeAws_json1_1StartApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidApplicationConfigurationException": case "com.amazonaws.kinesisanalytics#InvalidApplicationConfigurationException": @@ -1283,10 +1297,12 @@ const deserializeAws_json1_1StartApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1318,8 +1334,7 @@ const deserializeAws_json1_1StopApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.kinesisanalytics#ResourceInUseException": @@ -1332,10 +1347,12 @@ const deserializeAws_json1_1StopApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1367,8 +1384,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -1387,10 +1403,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1422,8 +1440,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.kinesisanalytics#ConcurrentModificationException": @@ -1442,10 +1459,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1477,8 +1496,7 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeValidationException": case "com.amazonaws.kinesisanalytics#CodeValidationException": @@ -1500,10 +1518,12 @@ const deserializeAws_json1_1UpdateApplicationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3336,7 +3356,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3362,6 +3382,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts index 91fdb09a38878..0a7aa47efeb66 100644 --- a/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video-archived-media/src/protocols/Aws_restJson1.ts @@ -291,8 +291,7 @@ const deserializeAws_restJson1GetClipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -323,10 +322,12 @@ const deserializeAws_restJson1GetClipCommandError = async ( throw await deserializeAws_restJson1UnsupportedStreamMediaTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -359,8 +360,7 @@ const deserializeAws_restJson1GetDASHStreamingSessionURLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -388,10 +388,12 @@ const deserializeAws_restJson1GetDASHStreamingSessionURLCommandError = async ( throw await deserializeAws_restJson1UnsupportedStreamMediaTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -424,8 +426,7 @@ const deserializeAws_restJson1GetHLSStreamingSessionURLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -453,10 +454,12 @@ const deserializeAws_restJson1GetHLSStreamingSessionURLCommandError = async ( throw await deserializeAws_restJson1UnsupportedStreamMediaTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -493,8 +496,7 @@ const deserializeAws_restJson1GetImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -510,10 +512,12 @@ const deserializeAws_restJson1GetImagesCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -548,8 +552,7 @@ const deserializeAws_restJson1GetMediaForFragmentListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -565,10 +568,12 @@ const deserializeAws_restJson1GetMediaForFragmentListCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -605,8 +610,7 @@ const deserializeAws_restJson1ListFragmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideoarchivedmedia#ClientLimitExceededException": @@ -622,10 +626,12 @@ const deserializeAws_restJson1ListFragmentsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -966,7 +972,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -992,6 +998,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts index 2257dfe140bfe..84840dbfcfddd 100644 --- a/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video-media/src/protocols/Aws_restJson1.ts @@ -80,8 +80,7 @@ const deserializeAws_restJson1GetMediaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideomedia#ClientLimitExceededException": @@ -103,10 +102,12 @@ const deserializeAws_restJson1GetMediaCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -258,7 +259,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -284,6 +285,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-video-signaling/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video-signaling/src/protocols/Aws_restJson1.ts index 5db245f01cb48..90b1ba0efbb50 100644 --- a/clients/client-kinesis-video-signaling/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video-signaling/src/protocols/Aws_restJson1.ts @@ -113,8 +113,7 @@ const deserializeAws_restJson1GetIceServerConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideosignaling#ClientLimitExceededException": @@ -136,10 +135,12 @@ const deserializeAws_restJson1GetIceServerConfigCommandError = async ( throw await deserializeAws_restJson1SessionExpiredExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -172,8 +173,7 @@ const deserializeAws_restJson1SendAlexaOfferToMasterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideosignaling#ClientLimitExceededException": @@ -189,10 +189,12 @@ const deserializeAws_restJson1SendAlexaOfferToMasterCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -367,7 +369,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -393,6 +395,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis-video/src/protocols/Aws_restJson1.ts b/clients/client-kinesis-video/src/protocols/Aws_restJson1.ts index 3e81c60af6ef5..408afd823c055 100644 --- a/clients/client-kinesis-video/src/protocols/Aws_restJson1.ts +++ b/clients/client-kinesis-video/src/protocols/Aws_restJson1.ts @@ -787,8 +787,7 @@ const deserializeAws_restJson1CreateSignalingChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -810,10 +809,12 @@ const deserializeAws_restJson1CreateSignalingChannelCommandError = async ( throw await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -846,8 +847,7 @@ const deserializeAws_restJson1CreateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountStreamLimitExceededException": case "com.amazonaws.kinesisvideo#AccountStreamLimitExceededException": @@ -872,10 +872,12 @@ const deserializeAws_restJson1CreateStreamCommandError = async ( throw await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -904,8 +906,7 @@ const deserializeAws_restJson1DeleteSignalingChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -927,10 +928,12 @@ const deserializeAws_restJson1DeleteSignalingChannelCommandError = async ( throw await deserializeAws_restJson1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,8 +962,7 @@ const deserializeAws_restJson1DeleteStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -982,10 +984,12 @@ const deserializeAws_restJson1DeleteStreamCommandError = async ( throw await deserializeAws_restJson1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1021,8 +1025,7 @@ const deserializeAws_restJson1DescribeImageGenerationConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1038,10 +1041,12 @@ const deserializeAws_restJson1DescribeImageGenerationConfigurationCommandError = throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1077,8 +1082,7 @@ const deserializeAws_restJson1DescribeNotificationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1094,10 +1098,12 @@ const deserializeAws_restJson1DescribeNotificationConfigurationCommandError = as throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1130,8 +1136,7 @@ const deserializeAws_restJson1DescribeSignalingChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1147,10 +1152,12 @@ const deserializeAws_restJson1DescribeSignalingChannelCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1183,8 +1190,7 @@ const deserializeAws_restJson1DescribeStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1200,10 +1206,12 @@ const deserializeAws_restJson1DescribeStreamCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1236,8 +1244,7 @@ const deserializeAws_restJson1GetDataEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1253,10 +1260,12 @@ const deserializeAws_restJson1GetDataEndpointCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1289,8 +1298,7 @@ const deserializeAws_restJson1GetSignalingChannelEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1309,10 +1317,12 @@ const deserializeAws_restJson1GetSignalingChannelEndpointCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1359,7 @@ const deserializeAws_restJson1ListSignalingChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1363,10 +1372,12 @@ const deserializeAws_restJson1ListSignalingChannelsCommandError = async ( throw await deserializeAws_restJson1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1403,8 +1414,7 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1414,10 +1424,12 @@ const deserializeAws_restJson1ListStreamsCommandError = async ( throw await deserializeAws_restJson1InvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1454,8 +1466,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1471,10 +1482,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1511,8 +1524,7 @@ const deserializeAws_restJson1ListTagsForStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1531,10 +1543,12 @@ const deserializeAws_restJson1ListTagsForStreamCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1563,8 +1577,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1583,10 +1596,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1615,8 +1630,7 @@ const deserializeAws_restJson1TagStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1638,10 +1652,12 @@ const deserializeAws_restJson1TagStreamCommandError = async ( throw await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1670,8 +1686,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1687,10 +1702,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1719,8 +1736,7 @@ const deserializeAws_restJson1UntagStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1739,10 +1755,12 @@ const deserializeAws_restJson1UntagStreamCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1771,8 +1789,7 @@ const deserializeAws_restJson1UpdateDataRetentionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -1794,10 +1811,12 @@ const deserializeAws_restJson1UpdateDataRetentionCommandError = async ( throw await deserializeAws_restJson1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1845,7 @@ const deserializeAws_restJson1UpdateImageGenerationConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1849,10 +1867,12 @@ const deserializeAws_restJson1UpdateImageGenerationConfigurationCommandError = a throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1881,8 +1901,7 @@ const deserializeAws_restJson1UpdateNotificationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1904,10 +1923,12 @@ const deserializeAws_restJson1UpdateNotificationConfigurationCommandError = asyn throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1936,8 +1957,7 @@ const deserializeAws_restJson1UpdateSignalingChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.kinesisvideo#AccessDeniedException": @@ -1959,10 +1979,12 @@ const deserializeAws_restJson1UpdateSignalingChannelCommandError = async ( throw await deserializeAws_restJson1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1991,8 +2013,7 @@ const deserializeAws_restJson1UpdateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClientLimitExceededException": case "com.amazonaws.kinesisvideo#ClientLimitExceededException": @@ -2014,10 +2035,12 @@ const deserializeAws_restJson1UpdateStreamCommandError = async ( throw await deserializeAws_restJson1VersionMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2624,7 +2647,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2650,6 +2673,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kinesis/src/protocols/Aws_json1_1.ts b/clients/client-kinesis/src/protocols/Aws_json1_1.ts index 0194c92a439c6..0a43508c1badd 100644 --- a/clients/client-kinesis/src/protocols/Aws_json1_1.ts +++ b/clients/client-kinesis/src/protocols/Aws_json1_1.ts @@ -566,8 +566,7 @@ const deserializeAws_json1_1AddTagsToStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -583,10 +582,12 @@ const deserializeAws_json1_1AddTagsToStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -615,8 +616,7 @@ const deserializeAws_json1_1CreateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -629,10 +629,12 @@ const deserializeAws_json1_1CreateStreamCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -661,8 +663,7 @@ const deserializeAws_json1_1DecreaseStreamRetentionPeriodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -678,10 +679,12 @@ const deserializeAws_json1_1DecreaseStreamRetentionPeriodCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -710,8 +713,7 @@ const deserializeAws_json1_1DeleteStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.kinesis#LimitExceededException": @@ -724,10 +726,12 @@ const deserializeAws_json1_1DeleteStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -756,8 +760,7 @@ const deserializeAws_json1_1DeregisterStreamConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -770,10 +773,12 @@ const deserializeAws_json1_1DeregisterStreamConsumerCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -805,18 +810,19 @@ const deserializeAws_json1_1DescribeLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.kinesis#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -848,8 +854,7 @@ const deserializeAws_json1_1DescribeStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.kinesis#LimitExceededException": @@ -859,10 +864,12 @@ const deserializeAws_json1_1DescribeStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -894,8 +901,7 @@ const deserializeAws_json1_1DescribeStreamConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -908,10 +914,12 @@ const deserializeAws_json1_1DescribeStreamConsumerCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -943,8 +951,7 @@ const deserializeAws_json1_1DescribeStreamSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.kinesis#LimitExceededException": @@ -954,10 +961,12 @@ const deserializeAws_json1_1DescribeStreamSummaryCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -989,8 +998,7 @@ const deserializeAws_json1_1DisableEnhancedMonitoringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1006,10 +1014,12 @@ const deserializeAws_json1_1DisableEnhancedMonitoringCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1041,8 +1051,7 @@ const deserializeAws_json1_1EnableEnhancedMonitoringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1058,10 +1067,12 @@ const deserializeAws_json1_1EnableEnhancedMonitoringCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1104,7 @@ const deserializeAws_json1_1GetRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredIteratorException": case "com.amazonaws.kinesis#ExpiredIteratorException": @@ -1128,10 +1138,12 @@ const deserializeAws_json1_1GetRecordsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1163,8 +1175,7 @@ const deserializeAws_json1_1GetShardIteratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1177,10 +1188,12 @@ const deserializeAws_json1_1GetShardIteratorCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1222,7 @@ const deserializeAws_json1_1IncreaseStreamRetentionPeriodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1226,10 +1238,12 @@ const deserializeAws_json1_1IncreaseStreamRetentionPeriodCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,8 +1275,7 @@ const deserializeAws_json1_1ListShardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredNextTokenException": case "com.amazonaws.kinesis#ExpiredNextTokenException": @@ -1281,10 +1294,12 @@ const deserializeAws_json1_1ListShardsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1316,8 +1331,7 @@ const deserializeAws_json1_1ListStreamConsumersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredNextTokenException": case "com.amazonaws.kinesis#ExpiredNextTokenException": @@ -1336,10 +1350,12 @@ const deserializeAws_json1_1ListStreamConsumersCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1371,18 +1387,19 @@ const deserializeAws_json1_1ListStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.kinesis#LimitExceededException": throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1414,8 +1431,7 @@ const deserializeAws_json1_1ListTagsForStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1428,10 +1444,12 @@ const deserializeAws_json1_1ListTagsForStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1460,8 +1478,7 @@ const deserializeAws_json1_1MergeShardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1480,10 +1497,12 @@ const deserializeAws_json1_1MergeShardsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1515,8 +1534,7 @@ const deserializeAws_json1_1PutRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1547,10 +1565,12 @@ const deserializeAws_json1_1PutRecordCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1602,7 @@ const deserializeAws_json1_1PutRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1614,10 +1633,12 @@ const deserializeAws_json1_1PutRecordsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1649,8 +1670,7 @@ const deserializeAws_json1_1RegisterStreamConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1666,10 +1686,12 @@ const deserializeAws_json1_1RegisterStreamConsumerCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1698,8 +1720,7 @@ const deserializeAws_json1_1RemoveTagsFromStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1715,10 +1736,12 @@ const deserializeAws_json1_1RemoveTagsFromStreamCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1747,8 +1770,7 @@ const deserializeAws_json1_1SplitShardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1767,10 +1789,12 @@ const deserializeAws_json1_1SplitShardCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1799,8 +1823,7 @@ const deserializeAws_json1_1StartStreamEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1834,10 +1857,12 @@ const deserializeAws_json1_1StartStreamEncryptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1866,8 +1891,7 @@ const deserializeAws_json1_1StopStreamEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1883,10 +1907,12 @@ const deserializeAws_json1_1StopStreamEncryptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1918,8 +1944,7 @@ const deserializeAws_json1_1SubscribeToShardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1935,10 +1960,12 @@ const deserializeAws_json1_1SubscribeToShardCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1970,8 +1997,7 @@ const deserializeAws_json1_1UpdateShardCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -1990,10 +2016,12 @@ const deserializeAws_json1_1UpdateShardCountCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2022,8 +2050,7 @@ const deserializeAws_json1_1UpdateStreamModeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgumentException": case "com.amazonaws.kinesis#InvalidArgumentException": @@ -2039,10 +2066,12 @@ const deserializeAws_json1_1UpdateStreamModeCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3330,7 +3359,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3356,6 +3385,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-kms/src/protocols/Aws_json1_1.ts b/clients/client-kms/src/protocols/Aws_json1_1.ts index 4f83c6cb09322..f453780ba2bd2 100644 --- a/clients/client-kms/src/protocols/Aws_json1_1.ts +++ b/clients/client-kms/src/protocols/Aws_json1_1.ts @@ -925,8 +925,7 @@ const deserializeAws_json1_1CancelKeyDeletionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -945,10 +944,12 @@ const deserializeAws_json1_1CancelKeyDeletionCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -980,8 +981,7 @@ const deserializeAws_json1_1ConnectCustomKeyStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmClusterInvalidConfigurationException": case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException": @@ -1000,10 +1000,12 @@ const deserializeAws_json1_1ConnectCustomKeyStoreCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1032,8 +1034,7 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.kms#AlreadyExistsException": @@ -1058,10 +1059,12 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1096,7 @@ const deserializeAws_json1_1CreateCustomKeyStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmClusterInUseException": case "com.amazonaws.kms#CloudHsmClusterInUseException": @@ -1119,10 +1121,12 @@ const deserializeAws_json1_1CreateCustomKeyStoreCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1154,8 +1158,7 @@ const deserializeAws_json1_1CreateGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1183,10 +1186,12 @@ const deserializeAws_json1_1CreateGrantCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1218,8 +1223,7 @@ const deserializeAws_json1_1CreateKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmClusterInvalidConfigurationException": case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException": @@ -1253,10 +1257,12 @@ const deserializeAws_json1_1CreateKeyCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1288,8 +1294,7 @@ const deserializeAws_json1_1DecryptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1323,10 +1328,12 @@ const deserializeAws_json1_1DecryptCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1355,8 +1362,7 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1372,10 +1378,12 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1407,8 +1415,7 @@ const deserializeAws_json1_1DeleteCustomKeyStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomKeyStoreHasCMKsException": case "com.amazonaws.kms#CustomKeyStoreHasCMKsException": @@ -1424,10 +1431,12 @@ const deserializeAws_json1_1DeleteCustomKeyStoreCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1456,8 +1465,7 @@ const deserializeAws_json1_1DeleteImportedKeyMaterialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1479,10 +1487,12 @@ const deserializeAws_json1_1DeleteImportedKeyMaterialCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1514,8 +1524,7 @@ const deserializeAws_json1_1DescribeCustomKeyStoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomKeyStoreNotFoundException": case "com.amazonaws.kms#CustomKeyStoreNotFoundException": @@ -1528,10 +1537,12 @@ const deserializeAws_json1_1DescribeCustomKeyStoresCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1563,8 +1574,7 @@ const deserializeAws_json1_1DescribeKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1580,10 +1590,12 @@ const deserializeAws_json1_1DescribeKeyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1612,8 +1624,7 @@ const deserializeAws_json1_1DisableKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1632,10 +1643,12 @@ const deserializeAws_json1_1DisableKeyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1664,8 +1677,7 @@ const deserializeAws_json1_1DisableKeyRotationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1690,10 +1702,12 @@ const deserializeAws_json1_1DisableKeyRotationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1725,8 +1739,7 @@ const deserializeAws_json1_1DisconnectCustomKeyStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomKeyStoreInvalidStateException": case "com.amazonaws.kms#CustomKeyStoreInvalidStateException": @@ -1739,10 +1752,12 @@ const deserializeAws_json1_1DisconnectCustomKeyStoreCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1771,8 +1786,7 @@ const deserializeAws_json1_1EnableKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1794,10 +1808,12 @@ const deserializeAws_json1_1EnableKeyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1842,7 @@ const deserializeAws_json1_1EnableKeyRotationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1852,10 +1867,12 @@ const deserializeAws_json1_1EnableKeyRotationCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1887,8 +1904,7 @@ const deserializeAws_json1_1EncryptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1916,10 +1932,12 @@ const deserializeAws_json1_1EncryptCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1951,8 +1969,7 @@ const deserializeAws_json1_1GenerateDataKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -1980,10 +1997,12 @@ const deserializeAws_json1_1GenerateDataKeyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2015,8 +2034,7 @@ const deserializeAws_json1_1GenerateDataKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2047,10 +2065,12 @@ const deserializeAws_json1_1GenerateDataKeyPairCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2082,8 +2102,7 @@ const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2114,10 +2133,12 @@ const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommandError = as throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2149,8 +2170,7 @@ const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2178,10 +2198,12 @@ const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommandError = async throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2213,8 +2235,7 @@ const deserializeAws_json1_1GenerateMacCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledException": case "com.amazonaws.kms#DisabledException": @@ -2239,10 +2260,12 @@ const deserializeAws_json1_1GenerateMacCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2274,8 +2297,7 @@ const deserializeAws_json1_1GenerateRandomCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomKeyStoreInvalidStateException": case "com.amazonaws.kms#CustomKeyStoreInvalidStateException": @@ -2291,10 +2313,12 @@ const deserializeAws_json1_1GenerateRandomCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2326,8 +2350,7 @@ const deserializeAws_json1_1GetKeyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2346,10 +2369,12 @@ const deserializeAws_json1_1GetKeyPolicyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2381,8 +2406,7 @@ const deserializeAws_json1_1GetKeyRotationStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2404,10 +2428,12 @@ const deserializeAws_json1_1GetKeyRotationStatusCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2439,8 +2465,7 @@ const deserializeAws_json1_1GetParametersForImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2462,10 +2487,12 @@ const deserializeAws_json1_1GetParametersForImportCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2497,8 +2524,7 @@ const deserializeAws_json1_1GetPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2532,10 +2558,12 @@ const deserializeAws_json1_1GetPublicKeyCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2567,8 +2595,7 @@ const deserializeAws_json1_1ImportKeyMaterialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2602,10 +2629,12 @@ const deserializeAws_json1_1ImportKeyMaterialCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2637,8 +2666,7 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2657,10 +2685,12 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2692,8 +2722,7 @@ const deserializeAws_json1_1ListGrantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2718,10 +2747,12 @@ const deserializeAws_json1_1ListGrantsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2753,8 +2784,7 @@ const deserializeAws_json1_1ListKeyPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2773,10 +2803,12 @@ const deserializeAws_json1_1ListKeyPoliciesCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2808,8 +2840,7 @@ const deserializeAws_json1_1ListKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2822,10 +2853,12 @@ const deserializeAws_json1_1ListKeysCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2857,8 +2890,7 @@ const deserializeAws_json1_1ListResourceTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.kms#InvalidArnException": @@ -2874,10 +2906,12 @@ const deserializeAws_json1_1ListResourceTagsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2909,8 +2943,7 @@ const deserializeAws_json1_1ListRetirableGrantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2929,10 +2962,12 @@ const deserializeAws_json1_1ListRetirableGrantsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2961,8 +2996,7 @@ const deserializeAws_json1_1PutKeyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -2990,10 +3024,12 @@ const deserializeAws_json1_1PutKeyPolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3025,8 +3061,7 @@ const deserializeAws_json1_1ReEncryptCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3060,10 +3095,12 @@ const deserializeAws_json1_1ReEncryptCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3095,8 +3132,7 @@ const deserializeAws_json1_1ReplicateKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.kms#AlreadyExistsException": @@ -3130,10 +3166,12 @@ const deserializeAws_json1_1ReplicateKeyCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3162,8 +3200,7 @@ const deserializeAws_json1_1RetireGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3188,10 +3225,12 @@ const deserializeAws_json1_1RetireGrantCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3220,8 +3259,7 @@ const deserializeAws_json1_1RevokeGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3243,10 +3281,12 @@ const deserializeAws_json1_1RevokeGrantCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3278,8 +3318,7 @@ const deserializeAws_json1_1ScheduleKeyDeletionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3298,10 +3337,12 @@ const deserializeAws_json1_1ScheduleKeyDeletionCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3333,8 +3374,7 @@ const deserializeAws_json1_1SignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3362,10 +3402,12 @@ const deserializeAws_json1_1SignCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3394,8 +3436,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.kms#InvalidArnException": @@ -3417,10 +3458,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3449,8 +3492,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArnException": case "com.amazonaws.kms#InvalidArnException": @@ -3469,10 +3511,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TagExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3501,8 +3545,7 @@ const deserializeAws_json1_1UpdateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3521,10 +3564,12 @@ const deserializeAws_json1_1UpdateAliasCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3556,8 +3601,7 @@ const deserializeAws_json1_1UpdateCustomKeyStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CloudHsmClusterInvalidConfigurationException": case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException": @@ -3585,10 +3629,12 @@ const deserializeAws_json1_1UpdateCustomKeyStoreCommandError = async ( throw await deserializeAws_json1_1KMSInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3617,8 +3663,7 @@ const deserializeAws_json1_1UpdateKeyDescriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3637,10 +3682,12 @@ const deserializeAws_json1_1UpdateKeyDescriptionCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3669,8 +3716,7 @@ const deserializeAws_json1_1UpdatePrimaryRegionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledException": case "com.amazonaws.kms#DisabledException": @@ -3692,10 +3738,12 @@ const deserializeAws_json1_1UpdatePrimaryRegionCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3727,8 +3775,7 @@ const deserializeAws_json1_1VerifyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependencyTimeoutException": case "com.amazonaws.kms#DependencyTimeoutException": @@ -3759,10 +3806,12 @@ const deserializeAws_json1_1VerifyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3794,8 +3843,7 @@ const deserializeAws_json1_1VerifyMacCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledException": case "com.amazonaws.kms#DisabledException": @@ -3823,10 +3871,12 @@ const deserializeAws_json1_1VerifyMacCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5934,7 +5984,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5960,6 +6010,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lakeformation/src/protocols/Aws_restJson1.ts b/clients/client-lakeformation/src/protocols/Aws_restJson1.ts index 04034d69d5cca..c3c561ed62480 100644 --- a/clients/client-lakeformation/src/protocols/Aws_restJson1.ts +++ b/clients/client-lakeformation/src/protocols/Aws_restJson1.ts @@ -1480,8 +1480,7 @@ const deserializeAws_restJson1AddLFTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -1503,10 +1502,12 @@ const deserializeAws_restJson1AddLFTagsToResourceCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1539,8 +1540,7 @@ const deserializeAws_restJson1BatchGrantPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.lakeformation#InvalidInputException": @@ -1550,10 +1550,12 @@ const deserializeAws_restJson1BatchGrantPermissionsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1586,8 +1588,7 @@ const deserializeAws_restJson1BatchRevokePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.lakeformation#InvalidInputException": @@ -1597,10 +1598,12 @@ const deserializeAws_restJson1BatchRevokePermissionsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1629,8 +1632,7 @@ const deserializeAws_restJson1CancelTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -1655,10 +1657,12 @@ const deserializeAws_restJson1CancelTransactionCommandError = async ( throw await deserializeAws_restJson1TransactionCommittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1691,8 +1695,7 @@ const deserializeAws_restJson1CommitTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -1714,10 +1717,12 @@ const deserializeAws_restJson1CommitTransactionCommandError = async ( throw await deserializeAws_restJson1TransactionCanceledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1746,8 +1751,7 @@ const deserializeAws_restJson1CreateDataCellsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -1772,10 +1776,12 @@ const deserializeAws_restJson1CreateDataCellsFilterCommandError = async ( throw await deserializeAws_restJson1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1804,8 +1810,7 @@ const deserializeAws_restJson1CreateLFTagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -1827,10 +1832,12 @@ const deserializeAws_restJson1CreateLFTagCommandError = async ( throw await deserializeAws_restJson1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1859,8 +1866,7 @@ const deserializeAws_restJson1DeleteDataCellsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -1879,10 +1885,12 @@ const deserializeAws_restJson1DeleteDataCellsFilterCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1911,8 +1919,7 @@ const deserializeAws_restJson1DeleteLFTagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -1931,10 +1938,12 @@ const deserializeAws_restJson1DeleteLFTagCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1963,8 +1972,7 @@ const deserializeAws_restJson1DeleteObjectsOnCancelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -1992,10 +2000,12 @@ const deserializeAws_restJson1DeleteObjectsOnCancelCommandError = async ( throw await deserializeAws_restJson1TransactionCommittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2024,8 +2034,7 @@ const deserializeAws_restJson1DeregisterResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2041,10 +2050,12 @@ const deserializeAws_restJson1DeregisterResourceCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,8 +2088,7 @@ const deserializeAws_restJson1DescribeResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2094,10 +2104,12 @@ const deserializeAws_restJson1DescribeResourceCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2145,7 @@ const deserializeAws_restJson1DescribeTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2150,10 +2161,12 @@ const deserializeAws_restJson1DescribeTransactionCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2195,7 @@ const deserializeAws_restJson1ExtendTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2208,10 +2220,12 @@ const deserializeAws_restJson1ExtendTransactionCommandError = async ( throw await deserializeAws_restJson1TransactionCommittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2244,8 +2258,7 @@ const deserializeAws_restJson1GetDataLakeSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2258,10 +2271,12 @@ const deserializeAws_restJson1GetDataLakeSettingsCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2298,8 +2313,7 @@ const deserializeAws_restJson1GetEffectivePermissionsForPathCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2315,10 +2329,12 @@ const deserializeAws_restJson1GetEffectivePermissionsForPathCommandError = async throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2359,8 +2375,7 @@ const deserializeAws_restJson1GetLFTagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2379,10 +2394,12 @@ const deserializeAws_restJson1GetLFTagCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2419,8 +2436,7 @@ const deserializeAws_restJson1GetQueryStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2433,10 +2449,12 @@ const deserializeAws_restJson1GetQueryStateCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2477,8 +2495,7 @@ const deserializeAws_restJson1GetQueryStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2500,10 +2517,12 @@ const deserializeAws_restJson1GetQueryStatisticsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2544,8 +2563,7 @@ const deserializeAws_restJson1GetResourceLFTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2567,10 +2585,12 @@ const deserializeAws_restJson1GetResourceLFTagsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2607,8 +2627,7 @@ const deserializeAws_restJson1GetTableObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -2633,10 +2652,12 @@ const deserializeAws_restJson1GetTableObjectsCommandError = async ( throw await deserializeAws_restJson1TransactionCommittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2681,8 +2702,7 @@ const deserializeAws_restJson1GetTemporaryGluePartitionCredentialsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2704,10 +2724,12 @@ const deserializeAws_restJson1GetTemporaryGluePartitionCredentialsCommandError = throw await deserializeAws_restJson1PermissionTypeMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2752,8 +2774,7 @@ const deserializeAws_restJson1GetTemporaryGlueTableCredentialsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2775,10 +2796,12 @@ const deserializeAws_restJson1GetTemporaryGlueTableCredentialsCommandError = asy throw await deserializeAws_restJson1PermissionTypeMismatchExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2809,8 +2832,7 @@ const deserializeAws_restJson1GetWorkUnitResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2829,10 +2851,12 @@ const deserializeAws_restJson1GetWorkUnitResultsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2873,8 +2897,7 @@ const deserializeAws_restJson1GetWorkUnitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2893,10 +2916,12 @@ const deserializeAws_restJson1GetWorkUnitsCommandError = async ( throw await deserializeAws_restJson1WorkUnitsNotReadyYetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2925,8 +2950,7 @@ const deserializeAws_restJson1GrantPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -2939,10 +2963,12 @@ const deserializeAws_restJson1GrantPermissionsCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2979,8 +3005,7 @@ const deserializeAws_restJson1ListDataCellsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -2996,10 +3021,12 @@ const deserializeAws_restJson1ListDataCellsFilterCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3036,8 +3063,7 @@ const deserializeAws_restJson1ListLFTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3056,10 +3082,12 @@ const deserializeAws_restJson1ListLFTagsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3099,8 +3127,7 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.lakeformation#InternalServiceException": @@ -3113,10 +3140,12 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3153,8 +3182,7 @@ const deserializeAws_restJson1ListResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.lakeformation#InternalServiceException": @@ -3167,10 +3195,12 @@ const deserializeAws_restJson1ListResourcesCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3207,8 +3237,7 @@ const deserializeAws_restJson1ListTableStorageOptimizersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3224,10 +3253,12 @@ const deserializeAws_restJson1ListTableStorageOptimizersCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3264,8 +3295,7 @@ const deserializeAws_restJson1ListTransactionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.lakeformation#InternalServiceException": @@ -3278,10 +3308,12 @@ const deserializeAws_restJson1ListTransactionsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3310,8 +3342,7 @@ const deserializeAws_restJson1PutDataLakeSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.lakeformation#InternalServiceException": @@ -3321,10 +3352,12 @@ const deserializeAws_restJson1PutDataLakeSettingsCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3353,8 +3386,7 @@ const deserializeAws_restJson1RegisterResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3379,10 +3411,12 @@ const deserializeAws_restJson1RegisterResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNumberLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3415,8 +3449,7 @@ const deserializeAws_restJson1RemoveLFTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3441,10 +3474,12 @@ const deserializeAws_restJson1RemoveLFTagsFromResourceCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3473,8 +3508,7 @@ const deserializeAws_restJson1RevokePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -3487,10 +3521,12 @@ const deserializeAws_restJson1RevokePermissionsCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3527,8 +3563,7 @@ const deserializeAws_restJson1SearchDatabasesByLFTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3550,10 +3585,12 @@ const deserializeAws_restJson1SearchDatabasesByLFTagsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3590,8 +3627,7 @@ const deserializeAws_restJson1SearchTablesByLFTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3613,10 +3649,12 @@ const deserializeAws_restJson1SearchTablesByLFTagsCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3649,8 +3687,7 @@ const deserializeAws_restJson1StartQueryPlanningCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3666,10 +3703,12 @@ const deserializeAws_restJson1StartQueryPlanningCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3702,8 +3741,7 @@ const deserializeAws_restJson1StartTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.lakeformation#InternalServiceException": @@ -3713,10 +3751,12 @@ const deserializeAws_restJson1StartTransactionCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3745,8 +3785,7 @@ const deserializeAws_restJson1UpdateLFTagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3768,10 +3807,12 @@ const deserializeAws_restJson1UpdateLFTagCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3800,8 +3841,7 @@ const deserializeAws_restJson1UpdateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.lakeformation#EntityNotFoundException": @@ -3817,10 +3857,12 @@ const deserializeAws_restJson1UpdateResourceCommandError = async ( throw await deserializeAws_restJson1OperationTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3849,8 +3891,7 @@ const deserializeAws_restJson1UpdateTableObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.lakeformation#ConcurrentModificationException": @@ -3881,10 +3922,12 @@ const deserializeAws_restJson1UpdateTableObjectsCommandError = async ( throw await deserializeAws_restJson1TransactionCommittedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3917,8 +3960,7 @@ const deserializeAws_restJson1UpdateTableStorageOptimizerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lakeformation#AccessDeniedException": @@ -3934,10 +3976,12 @@ const deserializeAws_restJson1UpdateTableStorageOptimizerCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5615,7 +5659,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5641,6 +5685,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lambda/src/protocols/Aws_restJson1.ts b/clients/client-lambda/src/protocols/Aws_restJson1.ts index ed08ae51b8194..accbaeeeb1777 100644 --- a/clients/client-lambda/src/protocols/Aws_restJson1.ts +++ b/clients/client-lambda/src/protocols/Aws_restJson1.ts @@ -2712,8 +2712,7 @@ const deserializeAws_restJson1AddLayerVersionPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -2738,10 +2737,12 @@ const deserializeAws_restJson1AddLayerVersionPermissionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2774,8 +2775,7 @@ const deserializeAws_restJson1AddPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -2800,10 +2800,12 @@ const deserializeAws_restJson1AddPermissionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2856,8 +2858,7 @@ const deserializeAws_restJson1CreateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -2876,10 +2877,12 @@ const deserializeAws_restJson1CreateAliasCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2912,8 +2915,7 @@ const deserializeAws_restJson1CreateCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -2923,10 +2925,12 @@ const deserializeAws_restJson1CreateCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3058,8 +3062,7 @@ const deserializeAws_restJson1CreateEventSourceMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3078,10 +3081,12 @@ const deserializeAws_restJson1CreateEventSourceMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3242,8 +3247,7 @@ const deserializeAws_restJson1CreateFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeSigningConfigNotFoundException": case "com.amazonaws.lambda#CodeSigningConfigNotFoundException": @@ -3274,10 +3278,12 @@ const deserializeAws_restJson1CreateFunctionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3326,8 +3332,7 @@ const deserializeAws_restJson1CreateFunctionUrlConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3346,10 +3351,12 @@ const deserializeAws_restJson1CreateFunctionUrlConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3378,8 +3385,7 @@ const deserializeAws_restJson1DeleteAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3395,10 +3401,12 @@ const deserializeAws_restJson1DeleteAliasCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3427,8 +3435,7 @@ const deserializeAws_restJson1DeleteCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3444,10 +3451,12 @@ const deserializeAws_restJson1DeleteCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3579,8 +3588,7 @@ const deserializeAws_restJson1DeleteEventSourceMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3599,10 +3607,12 @@ const deserializeAws_restJson1DeleteEventSourceMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3631,8 +3641,7 @@ const deserializeAws_restJson1DeleteFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3651,10 +3660,12 @@ const deserializeAws_restJson1DeleteFunctionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3683,8 +3694,7 @@ const deserializeAws_restJson1DeleteFunctionCodeSigningConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeSigningConfigNotFoundException": case "com.amazonaws.lambda#CodeSigningConfigNotFoundException": @@ -3706,10 +3716,12 @@ const deserializeAws_restJson1DeleteFunctionCodeSigningConfigCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3738,8 +3750,7 @@ const deserializeAws_restJson1DeleteFunctionConcurrencyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3758,10 +3769,12 @@ const deserializeAws_restJson1DeleteFunctionConcurrencyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3790,8 +3803,7 @@ const deserializeAws_restJson1DeleteFunctionEventInvokeConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3810,10 +3822,12 @@ const deserializeAws_restJson1DeleteFunctionEventInvokeConfigCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3842,8 +3856,7 @@ const deserializeAws_restJson1DeleteFunctionUrlConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceConflictException": case "com.amazonaws.lambda#ResourceConflictException": @@ -3859,10 +3872,12 @@ const deserializeAws_restJson1DeleteFunctionUrlConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3891,8 +3906,7 @@ const deserializeAws_restJson1DeleteLayerVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceException": case "com.amazonaws.lambda#ServiceException": @@ -3902,10 +3916,12 @@ const deserializeAws_restJson1DeleteLayerVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3934,8 +3950,7 @@ const deserializeAws_restJson1DeleteProvisionedConcurrencyConfigCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -3954,10 +3969,12 @@ const deserializeAws_restJson1DeleteProvisionedConcurrencyConfigCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3994,8 +4011,7 @@ const deserializeAws_restJson1GetAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceException": case "com.amazonaws.lambda#ServiceException": @@ -4005,10 +4021,12 @@ const deserializeAws_restJson1GetAccountSettingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4061,8 +4079,7 @@ const deserializeAws_restJson1GetAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4078,10 +4095,12 @@ const deserializeAws_restJson1GetAliasCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4114,8 +4133,7 @@ const deserializeAws_restJson1GetCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4128,10 +4146,12 @@ const deserializeAws_restJson1GetCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4263,8 +4283,7 @@ const deserializeAws_restJson1GetEventSourceMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4280,10 +4299,12 @@ const deserializeAws_restJson1GetEventSourceMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4328,8 +4349,7 @@ const deserializeAws_restJson1GetFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4345,10 +4365,12 @@ const deserializeAws_restJson1GetFunctionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4385,8 +4407,7 @@ const deserializeAws_restJson1GetFunctionCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4402,10 +4423,12 @@ const deserializeAws_restJson1GetFunctionCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4438,8 +4461,7 @@ const deserializeAws_restJson1GetFunctionConcurrencyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4455,10 +4477,12 @@ const deserializeAws_restJson1GetFunctionConcurrencyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4619,8 +4643,7 @@ const deserializeAws_restJson1GetFunctionConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4636,10 +4659,12 @@ const deserializeAws_restJson1GetFunctionConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4688,8 +4713,7 @@ const deserializeAws_restJson1GetFunctionEventInvokeConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4705,10 +4729,12 @@ const deserializeAws_restJson1GetFunctionEventInvokeConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4761,8 +4787,7 @@ const deserializeAws_restJson1GetFunctionUrlConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4778,10 +4803,12 @@ const deserializeAws_restJson1GetFunctionUrlConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4849,8 +4876,7 @@ const deserializeAws_restJson1GetLayerVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4866,10 +4892,12 @@ const deserializeAws_restJson1GetLayerVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4937,8 +4965,7 @@ const deserializeAws_restJson1GetLayerVersionByArnCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -4954,10 +4981,12 @@ const deserializeAws_restJson1GetLayerVersionByArnCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4994,8 +5023,7 @@ const deserializeAws_restJson1GetLayerVersionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5011,10 +5039,12 @@ const deserializeAws_restJson1GetLayerVersionPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5051,8 +5081,7 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5068,10 +5097,12 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5133,8 +5164,7 @@ const deserializeAws_restJson1GetProvisionedConcurrencyConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5153,10 +5183,12 @@ const deserializeAws_restJson1GetProvisionedConcurrencyConfigCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5203,8 +5235,7 @@ const deserializeAws_restJson1InvokeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EC2AccessDeniedException": case "com.amazonaws.lambda#EC2AccessDeniedException": @@ -5286,10 +5317,12 @@ const deserializeAws_restJson1InvokeCommandError = async ( throw await deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5322,8 +5355,7 @@ const deserializeAws_restJson1InvokeAsyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestContentException": case "com.amazonaws.lambda#InvalidRequestContentException": @@ -5342,10 +5374,12 @@ const deserializeAws_restJson1InvokeAsyncCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5382,8 +5416,7 @@ const deserializeAws_restJson1ListAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5399,10 +5432,12 @@ const deserializeAws_restJson1ListAliasesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5439,8 +5474,7 @@ const deserializeAws_restJson1ListCodeSigningConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5450,10 +5484,12 @@ const deserializeAws_restJson1ListCodeSigningConfigsCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5490,8 +5526,7 @@ const deserializeAws_restJson1ListEventSourceMappingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5507,10 +5542,12 @@ const deserializeAws_restJson1ListEventSourceMappingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5550,8 +5587,7 @@ const deserializeAws_restJson1ListFunctionEventInvokeConfigsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5567,10 +5603,12 @@ const deserializeAws_restJson1ListFunctionEventInvokeConfigsCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5607,8 +5645,7 @@ const deserializeAws_restJson1ListFunctionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5621,10 +5658,12 @@ const deserializeAws_restJson1ListFunctionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5661,8 +5700,7 @@ const deserializeAws_restJson1ListFunctionsByCodeSigningConfigCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5675,10 +5713,12 @@ const deserializeAws_restJson1ListFunctionsByCodeSigningConfigCommandError = asy throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5715,8 +5755,7 @@ const deserializeAws_restJson1ListFunctionUrlConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5732,10 +5771,12 @@ const deserializeAws_restJson1ListFunctionUrlConfigsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5772,8 +5813,7 @@ const deserializeAws_restJson1ListLayersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5786,10 +5826,12 @@ const deserializeAws_restJson1ListLayersCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5826,8 +5868,7 @@ const deserializeAws_restJson1ListLayerVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5843,10 +5884,12 @@ const deserializeAws_restJson1ListLayerVersionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5886,8 +5929,7 @@ const deserializeAws_restJson1ListProvisionedConcurrencyConfigsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5903,10 +5945,12 @@ const deserializeAws_restJson1ListProvisionedConcurrencyConfigsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5939,8 +5983,7 @@ const deserializeAws_restJson1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -5956,10 +5999,12 @@ const deserializeAws_restJson1ListTagsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5996,8 +6041,7 @@ const deserializeAws_restJson1ListVersionsByFunctionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6013,10 +6057,12 @@ const deserializeAws_restJson1ListVersionsByFunctionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6084,8 +6130,7 @@ const deserializeAws_restJson1PublishLayerVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeStorageExceededException": case "com.amazonaws.lambda#CodeStorageExceededException": @@ -6104,10 +6149,12 @@ const deserializeAws_restJson1PublishLayerVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6268,8 +6315,7 @@ const deserializeAws_restJson1PublishVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeStorageExceededException": case "com.amazonaws.lambda#CodeStorageExceededException": @@ -6294,10 +6340,12 @@ const deserializeAws_restJson1PublishVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6334,8 +6382,7 @@ const deserializeAws_restJson1PutFunctionCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeSigningConfigNotFoundException": case "com.amazonaws.lambda#CodeSigningConfigNotFoundException": @@ -6357,10 +6404,12 @@ const deserializeAws_restJson1PutFunctionCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6393,8 +6442,7 @@ const deserializeAws_restJson1PutFunctionConcurrencyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6413,10 +6461,12 @@ const deserializeAws_restJson1PutFunctionConcurrencyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6465,8 +6515,7 @@ const deserializeAws_restJson1PutFunctionEventInvokeConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6485,10 +6534,12 @@ const deserializeAws_restJson1PutFunctionEventInvokeConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6550,8 +6601,7 @@ const deserializeAws_restJson1PutProvisionedConcurrencyConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6570,10 +6620,12 @@ const deserializeAws_restJson1PutProvisionedConcurrencyConfigCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6602,8 +6654,7 @@ const deserializeAws_restJson1RemoveLayerVersionPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6622,10 +6673,12 @@ const deserializeAws_restJson1RemoveLayerVersionPermissionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6654,8 +6707,7 @@ const deserializeAws_restJson1RemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6674,10 +6726,12 @@ const deserializeAws_restJson1RemovePermissionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6706,8 +6760,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6726,10 +6779,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6758,8 +6813,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6778,10 +6832,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6834,8 +6890,7 @@ const deserializeAws_restJson1UpdateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6857,10 +6912,12 @@ const deserializeAws_restJson1UpdateAliasCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6893,8 +6950,7 @@ const deserializeAws_restJson1UpdateCodeSigningConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -6907,10 +6963,12 @@ const deserializeAws_restJson1UpdateCodeSigningConfigCommandError = async ( throw await deserializeAws_restJson1ServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7042,8 +7100,7 @@ const deserializeAws_restJson1UpdateEventSourceMappingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -7065,10 +7122,12 @@ const deserializeAws_restJson1UpdateEventSourceMappingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7229,8 +7288,7 @@ const deserializeAws_restJson1UpdateFunctionCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeSigningConfigNotFoundException": case "com.amazonaws.lambda#CodeSigningConfigNotFoundException": @@ -7264,10 +7322,12 @@ const deserializeAws_restJson1UpdateFunctionCodeCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7428,8 +7488,7 @@ const deserializeAws_restJson1UpdateFunctionConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CodeSigningConfigNotFoundException": case "com.amazonaws.lambda#CodeSigningConfigNotFoundException": @@ -7460,10 +7519,12 @@ const deserializeAws_restJson1UpdateFunctionConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7512,8 +7573,7 @@ const deserializeAws_restJson1UpdateFunctionEventInvokeConfigCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -7532,10 +7592,12 @@ const deserializeAws_restJson1UpdateFunctionEventInvokeConfigCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7588,8 +7650,7 @@ const deserializeAws_restJson1UpdateFunctionUrlConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.lambda#InvalidParameterValueException": @@ -7608,10 +7669,12 @@ const deserializeAws_restJson1UpdateFunctionUrlConfigCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9650,7 +9713,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9676,6 +9739,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lex-model-building-service/src/protocols/Aws_restJson1.ts b/clients/client-lex-model-building-service/src/protocols/Aws_restJson1.ts index 3cc50f2f971cc..a9744aec089e0 100644 --- a/clients/client-lex-model-building-service/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-model-building-service/src/protocols/Aws_restJson1.ts @@ -1725,8 +1725,7 @@ const deserializeAws_restJson1CreateBotVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -1748,10 +1747,12 @@ const deserializeAws_restJson1CreateBotVersionCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1852,8 +1853,7 @@ const deserializeAws_restJson1CreateIntentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -1875,10 +1875,12 @@ const deserializeAws_restJson1CreateIntentVersionCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1950,8 +1952,7 @@ const deserializeAws_restJson1CreateSlotTypeVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -1973,10 +1974,12 @@ const deserializeAws_restJson1CreateSlotTypeVersionCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2005,8 +2008,7 @@ const deserializeAws_restJson1DeleteBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2028,10 +2030,12 @@ const deserializeAws_restJson1DeleteBotCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2060,8 +2064,7 @@ const deserializeAws_restJson1DeleteBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2083,10 +2086,12 @@ const deserializeAws_restJson1DeleteBotAliasCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2115,8 +2120,7 @@ const deserializeAws_restJson1DeleteBotChannelAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2135,10 +2139,12 @@ const deserializeAws_restJson1DeleteBotChannelAssociationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2167,8 +2173,7 @@ const deserializeAws_restJson1DeleteBotVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2190,10 +2195,12 @@ const deserializeAws_restJson1DeleteBotVersionCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2222,8 +2229,7 @@ const deserializeAws_restJson1DeleteIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2245,10 +2251,12 @@ const deserializeAws_restJson1DeleteIntentCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2277,8 +2285,7 @@ const deserializeAws_restJson1DeleteIntentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2300,10 +2307,12 @@ const deserializeAws_restJson1DeleteIntentVersionCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2332,8 +2341,7 @@ const deserializeAws_restJson1DeleteSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2355,10 +2363,12 @@ const deserializeAws_restJson1DeleteSlotTypeCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2387,8 +2397,7 @@ const deserializeAws_restJson1DeleteSlotTypeVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2410,10 +2419,12 @@ const deserializeAws_restJson1DeleteSlotTypeVersionCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2442,8 +2453,7 @@ const deserializeAws_restJson1DeleteUtterancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2459,10 +2469,12 @@ const deserializeAws_restJson1DeleteUtterancesCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2563,8 +2575,7 @@ const deserializeAws_restJson1GetBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2580,10 +2591,12 @@ const deserializeAws_restJson1GetBotCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2644,8 +2657,7 @@ const deserializeAws_restJson1GetBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2661,10 +2673,12 @@ const deserializeAws_restJson1GetBotAliasCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2701,8 +2715,7 @@ const deserializeAws_restJson1GetBotAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2715,10 +2728,12 @@ const deserializeAws_restJson1GetBotAliasesCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2783,8 +2798,7 @@ const deserializeAws_restJson1GetBotChannelAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2800,10 +2814,12 @@ const deserializeAws_restJson1GetBotChannelAssociationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2843,8 +2859,7 @@ const deserializeAws_restJson1GetBotChannelAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2857,10 +2872,12 @@ const deserializeAws_restJson1GetBotChannelAssociationsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2897,8 +2914,7 @@ const deserializeAws_restJson1GetBotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2914,10 +2930,12 @@ const deserializeAws_restJson1GetBotsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2954,8 +2972,7 @@ const deserializeAws_restJson1GetBotVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -2971,10 +2988,12 @@ const deserializeAws_restJson1GetBotVersionsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3015,8 +3034,7 @@ const deserializeAws_restJson1GetBuiltinIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3032,10 +3050,12 @@ const deserializeAws_restJson1GetBuiltinIntentCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3072,8 +3092,7 @@ const deserializeAws_restJson1GetBuiltinIntentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3086,10 +3105,12 @@ const deserializeAws_restJson1GetBuiltinIntentsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3126,8 +3147,7 @@ const deserializeAws_restJson1GetBuiltinSlotTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3140,10 +3160,12 @@ const deserializeAws_restJson1GetBuiltinSlotTypesCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3200,8 +3222,7 @@ const deserializeAws_restJson1GetExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3217,10 +3238,12 @@ const deserializeAws_restJson1GetExportCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3277,8 +3300,7 @@ const deserializeAws_restJson1GetImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3294,10 +3316,12 @@ const deserializeAws_restJson1GetImportCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3398,8 +3422,7 @@ const deserializeAws_restJson1GetIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3415,10 +3438,12 @@ const deserializeAws_restJson1GetIntentCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3455,8 +3480,7 @@ const deserializeAws_restJson1GetIntentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3472,10 +3496,12 @@ const deserializeAws_restJson1GetIntentsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3512,8 +3538,7 @@ const deserializeAws_restJson1GetIntentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3529,10 +3554,12 @@ const deserializeAws_restJson1GetIntentVersionsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3601,8 +3628,7 @@ const deserializeAws_restJson1GetMigrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3618,10 +3644,12 @@ const deserializeAws_restJson1GetMigrationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3658,8 +3686,7 @@ const deserializeAws_restJson1GetMigrationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3672,10 +3699,12 @@ const deserializeAws_restJson1GetMigrationsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3747,8 +3776,7 @@ const deserializeAws_restJson1GetSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3764,10 +3792,12 @@ const deserializeAws_restJson1GetSlotTypeCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3804,8 +3834,7 @@ const deserializeAws_restJson1GetSlotTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3821,10 +3850,12 @@ const deserializeAws_restJson1GetSlotTypesCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3861,8 +3892,7 @@ const deserializeAws_restJson1GetSlotTypeVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3878,10 +3908,12 @@ const deserializeAws_restJson1GetSlotTypeVersionsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3918,8 +3950,7 @@ const deserializeAws_restJson1GetUtterancesViewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3932,10 +3963,12 @@ const deserializeAws_restJson1GetUtterancesViewCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3968,8 +4001,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -3985,10 +4017,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4097,8 +4131,7 @@ const deserializeAws_restJson1PutBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4117,10 +4150,12 @@ const deserializeAws_restJson1PutBotCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4185,8 +4220,7 @@ const deserializeAws_restJson1PutBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4205,10 +4239,12 @@ const deserializeAws_restJson1PutBotAliasCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4313,8 +4349,7 @@ const deserializeAws_restJson1PutIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4333,10 +4368,12 @@ const deserializeAws_restJson1PutIntentCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4412,8 +4449,7 @@ const deserializeAws_restJson1PutSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4432,10 +4468,12 @@ const deserializeAws_restJson1PutSlotTypeCommandError = async ( throw await deserializeAws_restJson1PreconditionFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4492,8 +4530,7 @@ const deserializeAws_restJson1StartImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4506,10 +4543,12 @@ const deserializeAws_restJson1StartImportCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4570,8 +4609,7 @@ const deserializeAws_restJson1StartMigrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexmodelbuildingservice#AccessDeniedException": @@ -4590,10 +4628,12 @@ const deserializeAws_restJson1StartMigrationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4622,8 +4662,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4642,10 +4681,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4674,8 +4715,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexmodelbuildingservice#BadRequestException": @@ -4694,10 +4734,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5947,7 +5989,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5973,6 +6015,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lex-models-v2/src/protocols/Aws_restJson1.ts b/clients/client-lex-models-v2/src/protocols/Aws_restJson1.ts index fd887ba4b11a1..2319690a45c2c 100644 --- a/clients/client-lex-models-v2/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-models-v2/src/protocols/Aws_restJson1.ts @@ -3434,8 +3434,7 @@ const deserializeAws_restJson1BuildBotLocaleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3457,10 +3456,12 @@ const deserializeAws_restJson1BuildBotLocaleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3529,8 +3530,7 @@ const deserializeAws_restJson1CreateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3552,10 +3552,12 @@ const deserializeAws_restJson1CreateBotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3637,8 +3639,7 @@ const deserializeAws_restJson1CreateBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3660,10 +3661,12 @@ const deserializeAws_restJson1CreateBotAliasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3728,8 +3731,7 @@ const deserializeAws_restJson1CreateBotLocaleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3751,10 +3753,12 @@ const deserializeAws_restJson1CreateBotLocaleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3810,8 +3814,7 @@ const deserializeAws_restJson1CreateBotVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3833,10 +3836,12 @@ const deserializeAws_restJson1CreateBotVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3888,8 +3893,7 @@ const deserializeAws_restJson1CreateExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -3911,10 +3915,12 @@ const deserializeAws_restJson1CreateExportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4013,8 +4019,7 @@ const deserializeAws_restJson1CreateIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4036,10 +4041,12 @@ const deserializeAws_restJson1CreateIntentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4076,8 +4083,7 @@ const deserializeAws_restJson1CreateResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -4099,10 +4105,12 @@ const deserializeAws_restJson1CreateResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4139,8 +4147,7 @@ const deserializeAws_restJson1CreateResourcePolicyStatementCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4165,10 +4172,12 @@ const deserializeAws_restJson1CreateResourcePolicyStatementCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4248,8 +4257,7 @@ const deserializeAws_restJson1CreateSlotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4271,10 +4279,12 @@ const deserializeAws_restJson1CreateSlotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4350,8 +4360,7 @@ const deserializeAws_restJson1CreateSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4373,10 +4382,12 @@ const deserializeAws_restJson1CreateSlotTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4413,8 +4424,7 @@ const deserializeAws_restJson1CreateUploadUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4433,10 +4443,12 @@ const deserializeAws_restJson1CreateUploadUrlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4473,8 +4485,7 @@ const deserializeAws_restJson1DeleteBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4496,10 +4507,12 @@ const deserializeAws_restJson1DeleteBotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4540,8 +4553,7 @@ const deserializeAws_restJson1DeleteBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4563,10 +4575,12 @@ const deserializeAws_restJson1DeleteBotAliasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4611,8 +4625,7 @@ const deserializeAws_restJson1DeleteBotLocaleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4634,10 +4647,12 @@ const deserializeAws_restJson1DeleteBotLocaleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4678,8 +4693,7 @@ const deserializeAws_restJson1DeleteBotVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4701,10 +4715,12 @@ const deserializeAws_restJson1DeleteBotVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4749,8 +4765,7 @@ const deserializeAws_restJson1DeleteCustomVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4772,10 +4787,12 @@ const deserializeAws_restJson1DeleteCustomVocabularyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4812,8 +4829,7 @@ const deserializeAws_restJson1DeleteExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -4832,10 +4848,12 @@ const deserializeAws_restJson1DeleteExportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4872,8 +4890,7 @@ const deserializeAws_restJson1DeleteImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -4892,10 +4909,12 @@ const deserializeAws_restJson1DeleteImportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4924,8 +4943,7 @@ const deserializeAws_restJson1DeleteIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -4947,10 +4965,12 @@ const deserializeAws_restJson1DeleteIntentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4987,8 +5007,7 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5004,10 +5023,12 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5044,8 +5065,7 @@ const deserializeAws_restJson1DeleteResourcePolicyStatementCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5061,10 +5081,12 @@ const deserializeAws_restJson1DeleteResourcePolicyStatementCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5093,8 +5115,7 @@ const deserializeAws_restJson1DeleteSlotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -5116,10 +5137,12 @@ const deserializeAws_restJson1DeleteSlotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5148,8 +5171,7 @@ const deserializeAws_restJson1DeleteSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -5171,10 +5193,12 @@ const deserializeAws_restJson1DeleteSlotTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5203,8 +5227,7 @@ const deserializeAws_restJson1DeleteUtterancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5217,10 +5240,12 @@ const deserializeAws_restJson1DeleteUtterancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5285,8 +5310,7 @@ const deserializeAws_restJson1DescribeBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5305,10 +5329,12 @@ const deserializeAws_restJson1DescribeBotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5397,8 +5423,7 @@ const deserializeAws_restJson1DescribeBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5417,10 +5442,12 @@ const deserializeAws_restJson1DescribeBotAliasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5518,8 +5545,7 @@ const deserializeAws_restJson1DescribeBotLocaleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5538,10 +5564,12 @@ const deserializeAws_restJson1DescribeBotLocaleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5620,8 +5648,7 @@ const deserializeAws_restJson1DescribeBotRecommendationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5637,10 +5664,12 @@ const deserializeAws_restJson1DescribeBotRecommendationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5709,8 +5738,7 @@ const deserializeAws_restJson1DescribeBotVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5729,10 +5757,12 @@ const deserializeAws_restJson1DescribeBotVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5785,8 +5815,7 @@ const deserializeAws_restJson1DescribeCustomVocabularyMetadataCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5805,10 +5834,12 @@ const deserializeAws_restJson1DescribeCustomVocabularyMetadataCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5872,8 +5903,7 @@ const deserializeAws_restJson1DescribeExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5889,10 +5919,12 @@ const deserializeAws_restJson1DescribeExportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5960,8 +5992,7 @@ const deserializeAws_restJson1DescribeImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -5977,10 +6008,12 @@ const deserializeAws_restJson1DescribeImportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6087,8 +6120,7 @@ const deserializeAws_restJson1DescribeIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6107,10 +6139,12 @@ const deserializeAws_restJson1DescribeIntentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6151,8 +6185,7 @@ const deserializeAws_restJson1DescribeResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6165,10 +6198,12 @@ const deserializeAws_restJson1DescribeResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6252,8 +6287,7 @@ const deserializeAws_restJson1DescribeSlotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6272,10 +6306,12 @@ const deserializeAws_restJson1DescribeSlotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6355,8 +6391,7 @@ const deserializeAws_restJson1DescribeSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6375,10 +6410,12 @@ const deserializeAws_restJson1DescribeSlotTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6459,8 +6496,7 @@ const deserializeAws_restJson1ListAggregatedUtterancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6476,10 +6512,12 @@ const deserializeAws_restJson1ListAggregatedUtterancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6520,8 +6558,7 @@ const deserializeAws_restJson1ListBotAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6537,10 +6574,12 @@ const deserializeAws_restJson1ListBotAliasesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6585,8 +6624,7 @@ const deserializeAws_restJson1ListBotLocalesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6602,10 +6640,12 @@ const deserializeAws_restJson1ListBotLocalesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6657,8 +6697,7 @@ const deserializeAws_restJson1ListBotRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6674,10 +6713,12 @@ const deserializeAws_restJson1ListBotRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6714,8 +6755,7 @@ const deserializeAws_restJson1ListBotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6731,10 +6771,12 @@ const deserializeAws_restJson1ListBotsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6775,8 +6817,7 @@ const deserializeAws_restJson1ListBotVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6792,10 +6833,12 @@ const deserializeAws_restJson1ListBotVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6839,8 +6882,7 @@ const deserializeAws_restJson1ListBuiltInIntentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6856,10 +6898,12 @@ const deserializeAws_restJson1ListBuiltInIntentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6903,8 +6947,7 @@ const deserializeAws_restJson1ListBuiltInSlotTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6920,10 +6963,12 @@ const deserializeAws_restJson1ListBuiltInSlotTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6972,8 +7017,7 @@ const deserializeAws_restJson1ListExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -6986,10 +7030,12 @@ const deserializeAws_restJson1ListExportsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7038,8 +7084,7 @@ const deserializeAws_restJson1ListImportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7052,10 +7097,12 @@ const deserializeAws_restJson1ListImportsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7104,8 +7151,7 @@ const deserializeAws_restJson1ListIntentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7121,10 +7167,12 @@ const deserializeAws_restJson1ListIntentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7177,8 +7225,7 @@ const deserializeAws_restJson1ListRecommendedIntentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7197,10 +7244,12 @@ const deserializeAws_restJson1ListRecommendedIntentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7253,8 +7302,7 @@ const deserializeAws_restJson1ListSlotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7270,10 +7318,12 @@ const deserializeAws_restJson1ListSlotsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7322,8 +7372,7 @@ const deserializeAws_restJson1ListSlotTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7339,10 +7388,12 @@ const deserializeAws_restJson1ListSlotTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7375,8 +7426,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7392,10 +7442,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7455,8 +7507,7 @@ const deserializeAws_restJson1SearchAssociatedTranscriptsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7475,10 +7526,12 @@ const deserializeAws_restJson1SearchAssociatedTranscriptsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7542,8 +7595,7 @@ const deserializeAws_restJson1StartBotRecommendationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -7568,10 +7620,12 @@ const deserializeAws_restJson1StartBotRecommendationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7623,8 +7677,7 @@ const deserializeAws_restJson1StartImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -7646,10 +7699,12 @@ const deserializeAws_restJson1StartImportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7678,8 +7733,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7695,10 +7749,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7727,8 +7783,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -7744,10 +7799,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7812,8 +7869,7 @@ const deserializeAws_restJson1UpdateBotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -7835,10 +7891,12 @@ const deserializeAws_restJson1UpdateBotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7920,8 +7978,7 @@ const deserializeAws_restJson1UpdateBotAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -7943,10 +8000,12 @@ const deserializeAws_restJson1UpdateBotAliasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8023,8 +8082,7 @@ const deserializeAws_restJson1UpdateBotLocaleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8046,10 +8104,12 @@ const deserializeAws_restJson1UpdateBotLocaleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8117,8 +8177,7 @@ const deserializeAws_restJson1UpdateBotRecommendationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8143,10 +8202,12 @@ const deserializeAws_restJson1UpdateBotRecommendationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8202,8 +8263,7 @@ const deserializeAws_restJson1UpdateExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8225,10 +8285,12 @@ const deserializeAws_restJson1UpdateExportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8335,8 +8397,7 @@ const deserializeAws_restJson1UpdateIntentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8358,10 +8419,12 @@ const deserializeAws_restJson1UpdateIntentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8398,8 +8461,7 @@ const deserializeAws_restJson1UpdateResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lexmodelsv2#InternalServerException": @@ -8421,10 +8483,12 @@ const deserializeAws_restJson1UpdateResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8508,8 +8572,7 @@ const deserializeAws_restJson1UpdateSlotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8531,10 +8594,12 @@ const deserializeAws_restJson1UpdateSlotCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8614,8 +8679,7 @@ const deserializeAws_restJson1UpdateSlotTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.lexmodelsv2#ConflictException": @@ -8637,10 +8701,12 @@ const deserializeAws_restJson1UpdateSlotTypeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11646,7 +11712,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -11672,6 +11738,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts b/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts index 4229df79db2fe..609aa9019c59f 100644 --- a/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-runtime-service/src/protocols/Aws_restJson1.ts @@ -388,8 +388,7 @@ const deserializeAws_restJson1DeleteSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexruntimeservice#BadRequestException": @@ -408,10 +407,12 @@ const deserializeAws_restJson1DeleteSessionCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -460,8 +461,7 @@ const deserializeAws_restJson1GetSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.lexruntimeservice#BadRequestException": @@ -477,10 +477,12 @@ const deserializeAws_restJson1GetSessionCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -589,8 +591,7 @@ const deserializeAws_restJson1PostContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.lexruntimeservice#BadGatewayException": @@ -627,10 +628,12 @@ const deserializeAws_restJson1PostContentCommandError = async ( throw await deserializeAws_restJson1UnsupportedMediaTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -715,8 +718,7 @@ const deserializeAws_restJson1PostTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.lexruntimeservice#BadGatewayException": @@ -744,10 +746,12 @@ const deserializeAws_restJson1PostTextCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -828,8 +832,7 @@ const deserializeAws_restJson1PutSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.lexruntimeservice#BadGatewayException": @@ -857,10 +860,12 @@ const deserializeAws_restJson1PutSessionCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1386,7 +1391,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1412,6 +1417,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts b/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts index 07ebc85c6994d..fe3ea612b6b0e 100644 --- a/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts +++ b/clients/client-lex-runtime-v2/src/protocols/Aws_restJson1.ts @@ -494,8 +494,7 @@ const deserializeAws_restJson1DeleteSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -517,10 +516,12 @@ const deserializeAws_restJson1DeleteSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -565,8 +566,7 @@ const deserializeAws_restJson1GetSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -585,10 +585,12 @@ const deserializeAws_restJson1GetSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -639,8 +641,7 @@ const deserializeAws_restJson1PutSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -668,10 +669,12 @@ const deserializeAws_restJson1PutSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -720,8 +723,7 @@ const deserializeAws_restJson1RecognizeTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -749,10 +751,12 @@ const deserializeAws_restJson1RecognizeTextCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -815,8 +819,7 @@ const deserializeAws_restJson1RecognizeUtteranceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -844,10 +847,12 @@ const deserializeAws_restJson1RecognizeUtteranceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -892,8 +897,7 @@ const deserializeAws_restJson1StartConversationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lexruntimev2#AccessDeniedException": @@ -909,10 +913,12 @@ const deserializeAws_restJson1StartConversationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2346,7 +2352,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2372,6 +2378,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-license-manager/src/protocols/Aws_json1_1.ts b/clients/client-license-manager/src/protocols/Aws_json1_1.ts index 44a27082dc822..56881d4a756ff 100644 --- a/clients/client-license-manager/src/protocols/Aws_json1_1.ts +++ b/clients/client-license-manager/src/protocols/Aws_json1_1.ts @@ -952,8 +952,7 @@ const deserializeAws_json1_1AcceptGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -978,10 +977,12 @@ const deserializeAws_json1_1AcceptGrantCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1013,8 +1014,7 @@ const deserializeAws_json1_1CheckInLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1042,10 +1042,12 @@ const deserializeAws_json1_1CheckInLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1077,8 +1079,7 @@ const deserializeAws_json1_1CheckoutBorrowLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1115,10 +1116,12 @@ const deserializeAws_json1_1CheckoutBorrowLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1150,8 +1153,7 @@ const deserializeAws_json1_1CheckoutLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1185,10 +1187,12 @@ const deserializeAws_json1_1CheckoutLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1220,8 +1224,7 @@ const deserializeAws_json1_1CreateGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1246,10 +1249,12 @@ const deserializeAws_json1_1CreateGrantCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1281,8 +1286,7 @@ const deserializeAws_json1_1CreateGrantVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1307,10 +1311,12 @@ const deserializeAws_json1_1CreateGrantVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1342,8 +1348,7 @@ const deserializeAws_json1_1CreateLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1368,10 +1373,12 @@ const deserializeAws_json1_1CreateLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1403,8 +1410,7 @@ const deserializeAws_json1_1CreateLicenseConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1426,10 +1432,12 @@ const deserializeAws_json1_1CreateLicenseConfigurationCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1461,8 +1469,7 @@ const deserializeAws_json1_1CreateLicenseConversionTaskForResourceCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1484,10 +1491,12 @@ const deserializeAws_json1_1CreateLicenseConversionTaskForResourceCommandError = throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1519,8 +1528,7 @@ const deserializeAws_json1_1CreateLicenseManagerReportGeneratorCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1548,10 +1556,12 @@ const deserializeAws_json1_1CreateLicenseManagerReportGeneratorCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1583,8 +1593,7 @@ const deserializeAws_json1_1CreateLicenseVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1612,10 +1621,12 @@ const deserializeAws_json1_1CreateLicenseVersionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1647,8 +1658,7 @@ const deserializeAws_json1_1CreateTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1676,10 +1686,12 @@ const deserializeAws_json1_1CreateTokenCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1711,8 +1723,7 @@ const deserializeAws_json1_1DeleteGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1737,10 +1748,12 @@ const deserializeAws_json1_1DeleteGrantCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1772,8 +1785,7 @@ const deserializeAws_json1_1DeleteLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1801,10 +1813,12 @@ const deserializeAws_json1_1DeleteLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1836,8 +1850,7 @@ const deserializeAws_json1_1DeleteLicenseConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1856,10 +1869,12 @@ const deserializeAws_json1_1DeleteLicenseConfigurationCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1891,8 +1906,7 @@ const deserializeAws_json1_1DeleteLicenseManagerReportGeneratorCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1920,10 +1934,12 @@ const deserializeAws_json1_1DeleteLicenseManagerReportGeneratorCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1955,8 +1971,7 @@ const deserializeAws_json1_1DeleteTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -1981,10 +1996,12 @@ const deserializeAws_json1_1DeleteTokenCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2016,8 +2033,7 @@ const deserializeAws_json1_1ExtendLicenseConsumptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2042,10 +2058,12 @@ const deserializeAws_json1_1ExtendLicenseConsumptionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,8 +2095,7 @@ const deserializeAws_json1_1GetAccessTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2097,10 +2114,12 @@ const deserializeAws_json1_1GetAccessTokenCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2132,8 +2151,7 @@ const deserializeAws_json1_1GetGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2158,10 +2176,12 @@ const deserializeAws_json1_1GetGrantCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2193,8 +2213,7 @@ const deserializeAws_json1_1GetLicenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2216,10 +2235,12 @@ const deserializeAws_json1_1GetLicenseCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2272,7 @@ const deserializeAws_json1_1GetLicenseConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2271,10 +2291,12 @@ const deserializeAws_json1_1GetLicenseConfigurationCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2306,8 +2328,7 @@ const deserializeAws_json1_1GetLicenseConversionTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2326,10 +2347,12 @@ const deserializeAws_json1_1GetLicenseConversionTaskCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2361,8 +2384,7 @@ const deserializeAws_json1_1GetLicenseManagerReportGeneratorCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2390,10 +2412,12 @@ const deserializeAws_json1_1GetLicenseManagerReportGeneratorCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2425,8 +2449,7 @@ const deserializeAws_json1_1GetLicenseUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2448,10 +2471,12 @@ const deserializeAws_json1_1GetLicenseUsageCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2483,8 +2508,7 @@ const deserializeAws_json1_1GetServiceSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2500,10 +2524,12 @@ const deserializeAws_json1_1GetServiceSettingsCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2535,8 +2561,7 @@ const deserializeAws_json1_1ListAssociationsForLicenseConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2558,10 +2583,12 @@ const deserializeAws_json1_1ListAssociationsForLicenseConfigurationCommandError throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2593,8 +2620,7 @@ const deserializeAws_json1_1ListDistributedGrantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2619,10 +2645,12 @@ const deserializeAws_json1_1ListDistributedGrantsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2654,8 +2682,7 @@ const deserializeAws_json1_1ListFailuresForLicenseConfigurationOperationsCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2674,10 +2701,12 @@ const deserializeAws_json1_1ListFailuresForLicenseConfigurationOperationsCommand throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2709,8 +2738,7 @@ const deserializeAws_json1_1ListLicenseConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2732,10 +2760,12 @@ const deserializeAws_json1_1ListLicenseConfigurationsCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2767,8 +2797,7 @@ const deserializeAws_json1_1ListLicenseConversionTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2787,10 +2816,12 @@ const deserializeAws_json1_1ListLicenseConversionTasksCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2822,8 +2853,7 @@ const deserializeAws_json1_1ListLicenseManagerReportGeneratorsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2851,10 +2881,12 @@ const deserializeAws_json1_1ListLicenseManagerReportGeneratorsCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2886,8 +2918,7 @@ const deserializeAws_json1_1ListLicensesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2909,10 +2940,12 @@ const deserializeAws_json1_1ListLicensesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2944,8 +2977,7 @@ const deserializeAws_json1_1ListLicenseSpecificationsForResourceCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -2964,10 +2996,12 @@ const deserializeAws_json1_1ListLicenseSpecificationsForResourceCommandError = a throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2999,8 +3033,7 @@ const deserializeAws_json1_1ListLicenseVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3019,10 +3052,12 @@ const deserializeAws_json1_1ListLicenseVersionsCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3054,8 +3089,7 @@ const deserializeAws_json1_1ListReceivedGrantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3080,10 +3114,12 @@ const deserializeAws_json1_1ListReceivedGrantsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3115,8 +3151,7 @@ const deserializeAws_json1_1ListReceivedLicensesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3141,10 +3176,12 @@ const deserializeAws_json1_1ListReceivedLicensesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3176,8 +3213,7 @@ const deserializeAws_json1_1ListResourceInventoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3202,10 +3238,12 @@ const deserializeAws_json1_1ListResourceInventoryCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3237,8 +3275,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3257,10 +3294,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3292,8 +3331,7 @@ const deserializeAws_json1_1ListTokensCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3312,10 +3350,12 @@ const deserializeAws_json1_1ListTokensCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3347,8 +3387,7 @@ const deserializeAws_json1_1ListUsageForLicenseConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3370,10 +3409,12 @@ const deserializeAws_json1_1ListUsageForLicenseConfigurationCommandError = async throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3405,8 +3446,7 @@ const deserializeAws_json1_1RejectGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3431,10 +3471,12 @@ const deserializeAws_json1_1RejectGrantCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3466,8 +3508,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3486,10 +3527,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3521,8 +3564,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3541,10 +3583,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3576,8 +3620,7 @@ const deserializeAws_json1_1UpdateLicenseConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3599,10 +3642,12 @@ const deserializeAws_json1_1UpdateLicenseConfigurationCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3634,8 +3679,7 @@ const deserializeAws_json1_1UpdateLicenseManagerReportGeneratorCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3663,10 +3707,12 @@ const deserializeAws_json1_1UpdateLicenseManagerReportGeneratorCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3698,8 +3744,7 @@ const deserializeAws_json1_1UpdateLicenseSpecificationsForResourceCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3724,10 +3769,12 @@ const deserializeAws_json1_1UpdateLicenseSpecificationsForResourceCommandError = throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3759,8 +3806,7 @@ const deserializeAws_json1_1UpdateServiceSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.licensemanager#AccessDeniedException": @@ -3779,10 +3825,12 @@ const deserializeAws_json1_1UpdateServiceSettingsCommandError = async ( throw await deserializeAws_json1_1ServerInternalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6583,7 +6631,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6609,6 +6657,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lightsail/src/protocols/Aws_json1_1.ts b/clients/client-lightsail/src/protocols/Aws_json1_1.ts index b13dd438e75c5..7ebba35a7f905 100644 --- a/clients/client-lightsail/src/protocols/Aws_json1_1.ts +++ b/clients/client-lightsail/src/protocols/Aws_json1_1.ts @@ -2862,8 +2862,7 @@ const deserializeAws_json1_1AllocateStaticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -2888,10 +2887,12 @@ const deserializeAws_json1_1AllocateStaticIpCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2923,8 +2924,7 @@ const deserializeAws_json1_1AttachCertificateToDistributionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -2946,10 +2946,12 @@ const deserializeAws_json1_1AttachCertificateToDistributionCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2981,8 +2983,7 @@ const deserializeAws_json1_1AttachDiskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3007,10 +3008,12 @@ const deserializeAws_json1_1AttachDiskCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3042,8 +3045,7 @@ const deserializeAws_json1_1AttachInstancesToLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3068,10 +3070,12 @@ const deserializeAws_json1_1AttachInstancesToLoadBalancerCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3103,8 +3107,7 @@ const deserializeAws_json1_1AttachLoadBalancerTlsCertificateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3129,10 +3132,12 @@ const deserializeAws_json1_1AttachLoadBalancerTlsCertificateCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3164,8 +3169,7 @@ const deserializeAws_json1_1AttachStaticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3190,10 +3194,12 @@ const deserializeAws_json1_1AttachStaticIpCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3225,8 +3231,7 @@ const deserializeAws_json1_1CloseInstancePublicPortsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3251,10 +3256,12 @@ const deserializeAws_json1_1CloseInstancePublicPortsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3286,8 +3293,7 @@ const deserializeAws_json1_1CopySnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3312,10 +3318,12 @@ const deserializeAws_json1_1CopySnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3347,8 +3355,7 @@ const deserializeAws_json1_1CreateBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3364,10 +3371,12 @@ const deserializeAws_json1_1CreateBucketCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3399,8 +3408,7 @@ const deserializeAws_json1_1CreateBucketAccessKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3419,10 +3427,12 @@ const deserializeAws_json1_1CreateBucketAccessKeyCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3454,8 +3464,7 @@ const deserializeAws_json1_1CreateCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3474,10 +3483,12 @@ const deserializeAws_json1_1CreateCertificateCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3509,8 +3520,7 @@ const deserializeAws_json1_1CreateCloudFormationStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3535,10 +3545,12 @@ const deserializeAws_json1_1CreateCloudFormationStackCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3570,8 +3582,7 @@ const deserializeAws_json1_1CreateContactMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3593,10 +3604,12 @@ const deserializeAws_json1_1CreateContactMethodCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3628,8 +3641,7 @@ const deserializeAws_json1_1CreateContainerServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3648,10 +3660,12 @@ const deserializeAws_json1_1CreateContainerServiceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3683,8 +3697,7 @@ const deserializeAws_json1_1CreateContainerServiceDeploymentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3703,10 +3716,12 @@ const deserializeAws_json1_1CreateContainerServiceDeploymentCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3738,8 +3753,7 @@ const deserializeAws_json1_1CreateContainerServiceRegistryLoginCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3758,10 +3772,12 @@ const deserializeAws_json1_1CreateContainerServiceRegistryLoginCommandError = as throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3793,8 +3809,7 @@ const deserializeAws_json1_1CreateDiskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3819,10 +3834,12 @@ const deserializeAws_json1_1CreateDiskCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3854,8 +3871,7 @@ const deserializeAws_json1_1CreateDiskFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3880,10 +3896,12 @@ const deserializeAws_json1_1CreateDiskFromSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3915,8 +3933,7 @@ const deserializeAws_json1_1CreateDiskSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3941,10 +3958,12 @@ const deserializeAws_json1_1CreateDiskSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3976,8 +3995,7 @@ const deserializeAws_json1_1CreateDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -3999,10 +4017,12 @@ const deserializeAws_json1_1CreateDistributionCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4034,8 +4054,7 @@ const deserializeAws_json1_1CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4060,10 +4079,12 @@ const deserializeAws_json1_1CreateDomainCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4095,8 +4116,7 @@ const deserializeAws_json1_1CreateDomainEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4121,10 +4141,12 @@ const deserializeAws_json1_1CreateDomainEntryCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4156,8 +4178,7 @@ const deserializeAws_json1_1CreateInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4182,10 +4203,12 @@ const deserializeAws_json1_1CreateInstancesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4217,8 +4240,7 @@ const deserializeAws_json1_1CreateInstancesFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4243,10 +4265,12 @@ const deserializeAws_json1_1CreateInstancesFromSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4278,8 +4302,7 @@ const deserializeAws_json1_1CreateInstanceSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4304,10 +4327,12 @@ const deserializeAws_json1_1CreateInstanceSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4339,8 +4364,7 @@ const deserializeAws_json1_1CreateKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4365,10 +4389,12 @@ const deserializeAws_json1_1CreateKeyPairCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4400,8 +4426,7 @@ const deserializeAws_json1_1CreateLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4426,10 +4451,12 @@ const deserializeAws_json1_1CreateLoadBalancerCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4461,8 +4488,7 @@ const deserializeAws_json1_1CreateLoadBalancerTlsCertificateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4487,10 +4513,12 @@ const deserializeAws_json1_1CreateLoadBalancerTlsCertificateCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4522,8 +4550,7 @@ const deserializeAws_json1_1CreateRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4548,10 +4575,12 @@ const deserializeAws_json1_1CreateRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4583,8 +4612,7 @@ const deserializeAws_json1_1CreateRelationalDatabaseFromSnapshotCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4609,10 +4637,12 @@ const deserializeAws_json1_1CreateRelationalDatabaseFromSnapshotCommandError = a throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4644,8 +4674,7 @@ const deserializeAws_json1_1CreateRelationalDatabaseSnapshotCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4670,10 +4699,12 @@ const deserializeAws_json1_1CreateRelationalDatabaseSnapshotCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4705,8 +4736,7 @@ const deserializeAws_json1_1DeleteAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4728,10 +4758,12 @@ const deserializeAws_json1_1DeleteAlarmCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4763,8 +4795,7 @@ const deserializeAws_json1_1DeleteAutoSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4786,10 +4817,12 @@ const deserializeAws_json1_1DeleteAutoSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4821,8 +4854,7 @@ const deserializeAws_json1_1DeleteBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4841,10 +4873,12 @@ const deserializeAws_json1_1DeleteBucketCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4876,8 +4910,7 @@ const deserializeAws_json1_1DeleteBucketAccessKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4896,10 +4929,12 @@ const deserializeAws_json1_1DeleteBucketAccessKeyCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4931,8 +4966,7 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -4951,10 +4985,12 @@ const deserializeAws_json1_1DeleteCertificateCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4986,8 +5022,7 @@ const deserializeAws_json1_1DeleteContactMethodCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5009,10 +5044,12 @@ const deserializeAws_json1_1DeleteContactMethodCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5044,8 +5081,7 @@ const deserializeAws_json1_1DeleteContainerImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5064,10 +5100,12 @@ const deserializeAws_json1_1DeleteContainerImageCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5099,8 +5137,7 @@ const deserializeAws_json1_1DeleteContainerServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5119,10 +5156,12 @@ const deserializeAws_json1_1DeleteContainerServiceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5154,8 +5193,7 @@ const deserializeAws_json1_1DeleteDiskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5180,10 +5218,12 @@ const deserializeAws_json1_1DeleteDiskCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5215,8 +5255,7 @@ const deserializeAws_json1_1DeleteDiskSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5241,10 +5280,12 @@ const deserializeAws_json1_1DeleteDiskSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5276,8 +5317,7 @@ const deserializeAws_json1_1DeleteDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5299,10 +5339,12 @@ const deserializeAws_json1_1DeleteDistributionCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5334,8 +5376,7 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5360,10 +5401,12 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5395,8 +5438,7 @@ const deserializeAws_json1_1DeleteDomainEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5421,10 +5463,12 @@ const deserializeAws_json1_1DeleteDomainEntryCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5456,8 +5500,7 @@ const deserializeAws_json1_1DeleteInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5482,10 +5525,12 @@ const deserializeAws_json1_1DeleteInstanceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5517,8 +5562,7 @@ const deserializeAws_json1_1DeleteInstanceSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5543,10 +5587,12 @@ const deserializeAws_json1_1DeleteInstanceSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5578,8 +5624,7 @@ const deserializeAws_json1_1DeleteKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5604,10 +5649,12 @@ const deserializeAws_json1_1DeleteKeyPairCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5639,8 +5686,7 @@ const deserializeAws_json1_1DeleteKnownHostKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5665,10 +5711,12 @@ const deserializeAws_json1_1DeleteKnownHostKeysCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5700,8 +5748,7 @@ const deserializeAws_json1_1DeleteLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5726,10 +5773,12 @@ const deserializeAws_json1_1DeleteLoadBalancerCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5761,8 +5810,7 @@ const deserializeAws_json1_1DeleteLoadBalancerTlsCertificateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5787,10 +5835,12 @@ const deserializeAws_json1_1DeleteLoadBalancerTlsCertificateCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5822,8 +5872,7 @@ const deserializeAws_json1_1DeleteRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5848,10 +5897,12 @@ const deserializeAws_json1_1DeleteRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5883,8 +5934,7 @@ const deserializeAws_json1_1DeleteRelationalDatabaseSnapshotCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5909,10 +5959,12 @@ const deserializeAws_json1_1DeleteRelationalDatabaseSnapshotCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5944,8 +5996,7 @@ const deserializeAws_json1_1DetachCertificateFromDistributionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -5967,10 +6018,12 @@ const deserializeAws_json1_1DetachCertificateFromDistributionCommandError = asyn throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6002,8 +6055,7 @@ const deserializeAws_json1_1DetachDiskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6028,10 +6080,12 @@ const deserializeAws_json1_1DetachDiskCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6063,8 +6117,7 @@ const deserializeAws_json1_1DetachInstancesFromLoadBalancerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6089,10 +6142,12 @@ const deserializeAws_json1_1DetachInstancesFromLoadBalancerCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6124,8 +6179,7 @@ const deserializeAws_json1_1DetachStaticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6150,10 +6204,12 @@ const deserializeAws_json1_1DetachStaticIpCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6185,8 +6241,7 @@ const deserializeAws_json1_1DisableAddOnCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6208,10 +6263,12 @@ const deserializeAws_json1_1DisableAddOnCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6243,8 +6300,7 @@ const deserializeAws_json1_1DownloadDefaultKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6269,10 +6325,12 @@ const deserializeAws_json1_1DownloadDefaultKeyPairCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6304,8 +6362,7 @@ const deserializeAws_json1_1EnableAddOnCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6327,10 +6384,12 @@ const deserializeAws_json1_1EnableAddOnCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6362,8 +6421,7 @@ const deserializeAws_json1_1ExportSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6388,10 +6446,12 @@ const deserializeAws_json1_1ExportSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6423,8 +6483,7 @@ const deserializeAws_json1_1GetActiveNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6449,10 +6508,12 @@ const deserializeAws_json1_1GetActiveNamesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6484,8 +6545,7 @@ const deserializeAws_json1_1GetAlarmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6507,10 +6567,12 @@ const deserializeAws_json1_1GetAlarmsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6542,8 +6604,7 @@ const deserializeAws_json1_1GetAutoSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6565,10 +6626,12 @@ const deserializeAws_json1_1GetAutoSnapshotsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6600,8 +6663,7 @@ const deserializeAws_json1_1GetBlueprintsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6626,10 +6688,12 @@ const deserializeAws_json1_1GetBlueprintsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6661,8 +6725,7 @@ const deserializeAws_json1_1GetBucketAccessKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6681,10 +6744,12 @@ const deserializeAws_json1_1GetBucketAccessKeysCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6716,8 +6781,7 @@ const deserializeAws_json1_1GetBucketBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6733,10 +6797,12 @@ const deserializeAws_json1_1GetBucketBundlesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6768,8 +6834,7 @@ const deserializeAws_json1_1GetBucketMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6788,10 +6853,12 @@ const deserializeAws_json1_1GetBucketMetricDataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6823,8 +6890,7 @@ const deserializeAws_json1_1GetBucketsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6843,10 +6909,12 @@ const deserializeAws_json1_1GetBucketsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6878,8 +6946,7 @@ const deserializeAws_json1_1GetBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6904,10 +6971,12 @@ const deserializeAws_json1_1GetBundlesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6939,8 +7008,7 @@ const deserializeAws_json1_1GetCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -6959,10 +7027,12 @@ const deserializeAws_json1_1GetCertificatesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6994,8 +7064,7 @@ const deserializeAws_json1_1GetCloudFormationStackRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7020,10 +7089,12 @@ const deserializeAws_json1_1GetCloudFormationStackRecordsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7055,8 +7126,7 @@ const deserializeAws_json1_1GetContactMethodsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7078,10 +7148,12 @@ const deserializeAws_json1_1GetContactMethodsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7113,8 +7185,7 @@ const deserializeAws_json1_1GetContainerAPIMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7127,10 +7198,12 @@ const deserializeAws_json1_1GetContainerAPIMetadataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7162,8 +7235,7 @@ const deserializeAws_json1_1GetContainerImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7182,10 +7254,12 @@ const deserializeAws_json1_1GetContainerImagesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7217,8 +7291,7 @@ const deserializeAws_json1_1GetContainerLogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7237,10 +7310,12 @@ const deserializeAws_json1_1GetContainerLogCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7272,8 +7347,7 @@ const deserializeAws_json1_1GetContainerServiceDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7292,10 +7366,12 @@ const deserializeAws_json1_1GetContainerServiceDeploymentsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7327,8 +7403,7 @@ const deserializeAws_json1_1GetContainerServiceMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7347,10 +7422,12 @@ const deserializeAws_json1_1GetContainerServiceMetricDataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7382,8 +7459,7 @@ const deserializeAws_json1_1GetContainerServicePowersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7402,10 +7478,12 @@ const deserializeAws_json1_1GetContainerServicePowersCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7437,8 +7515,7 @@ const deserializeAws_json1_1GetContainerServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7457,10 +7534,12 @@ const deserializeAws_json1_1GetContainerServicesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7492,8 +7571,7 @@ const deserializeAws_json1_1GetDiskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7518,10 +7596,12 @@ const deserializeAws_json1_1GetDiskCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7553,8 +7633,7 @@ const deserializeAws_json1_1GetDisksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7579,10 +7658,12 @@ const deserializeAws_json1_1GetDisksCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7614,8 +7695,7 @@ const deserializeAws_json1_1GetDiskSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7640,10 +7720,12 @@ const deserializeAws_json1_1GetDiskSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7675,8 +7757,7 @@ const deserializeAws_json1_1GetDiskSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7701,10 +7782,12 @@ const deserializeAws_json1_1GetDiskSnapshotsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7736,8 +7819,7 @@ const deserializeAws_json1_1GetDistributionBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7759,10 +7841,12 @@ const deserializeAws_json1_1GetDistributionBundlesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7794,8 +7878,7 @@ const deserializeAws_json1_1GetDistributionLatestCacheResetCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7817,10 +7900,12 @@ const deserializeAws_json1_1GetDistributionLatestCacheResetCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7852,8 +7937,7 @@ const deserializeAws_json1_1GetDistributionMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7875,10 +7959,12 @@ const deserializeAws_json1_1GetDistributionMetricDataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7910,8 +7996,7 @@ const deserializeAws_json1_1GetDistributionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7933,10 +8018,12 @@ const deserializeAws_json1_1GetDistributionsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7968,8 +8055,7 @@ const deserializeAws_json1_1GetDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -7994,10 +8080,12 @@ const deserializeAws_json1_1GetDomainCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8029,8 +8117,7 @@ const deserializeAws_json1_1GetDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8055,10 +8142,12 @@ const deserializeAws_json1_1GetDomainsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8090,8 +8179,7 @@ const deserializeAws_json1_1GetExportSnapshotRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8116,10 +8204,12 @@ const deserializeAws_json1_1GetExportSnapshotRecordsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8151,8 +8241,7 @@ const deserializeAws_json1_1GetInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8177,10 +8266,12 @@ const deserializeAws_json1_1GetInstanceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8212,8 +8303,7 @@ const deserializeAws_json1_1GetInstanceAccessDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8238,10 +8328,12 @@ const deserializeAws_json1_1GetInstanceAccessDetailsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8273,8 +8365,7 @@ const deserializeAws_json1_1GetInstanceMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8299,10 +8390,12 @@ const deserializeAws_json1_1GetInstanceMetricDataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8334,8 +8427,7 @@ const deserializeAws_json1_1GetInstancePortStatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8360,10 +8452,12 @@ const deserializeAws_json1_1GetInstancePortStatesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8395,8 +8489,7 @@ const deserializeAws_json1_1GetInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8421,10 +8514,12 @@ const deserializeAws_json1_1GetInstancesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8456,8 +8551,7 @@ const deserializeAws_json1_1GetInstanceSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8482,10 +8576,12 @@ const deserializeAws_json1_1GetInstanceSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8517,8 +8613,7 @@ const deserializeAws_json1_1GetInstanceSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8543,10 +8638,12 @@ const deserializeAws_json1_1GetInstanceSnapshotsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8578,8 +8675,7 @@ const deserializeAws_json1_1GetInstanceStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8604,10 +8700,12 @@ const deserializeAws_json1_1GetInstanceStateCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8639,8 +8737,7 @@ const deserializeAws_json1_1GetKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8665,10 +8762,12 @@ const deserializeAws_json1_1GetKeyPairCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8700,8 +8799,7 @@ const deserializeAws_json1_1GetKeyPairsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8726,10 +8824,12 @@ const deserializeAws_json1_1GetKeyPairsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8761,8 +8861,7 @@ const deserializeAws_json1_1GetLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8787,10 +8886,12 @@ const deserializeAws_json1_1GetLoadBalancerCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8822,8 +8923,7 @@ const deserializeAws_json1_1GetLoadBalancerMetricDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8848,10 +8948,12 @@ const deserializeAws_json1_1GetLoadBalancerMetricDataCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8883,8 +8985,7 @@ const deserializeAws_json1_1GetLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8909,10 +9010,12 @@ const deserializeAws_json1_1GetLoadBalancersCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8944,8 +9047,7 @@ const deserializeAws_json1_1GetLoadBalancerTlsCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -8970,10 +9072,12 @@ const deserializeAws_json1_1GetLoadBalancerTlsCertificatesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9005,8 +9109,7 @@ const deserializeAws_json1_1GetLoadBalancerTlsPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9025,10 +9128,12 @@ const deserializeAws_json1_1GetLoadBalancerTlsPoliciesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9060,8 +9165,7 @@ const deserializeAws_json1_1GetOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9086,10 +9190,12 @@ const deserializeAws_json1_1GetOperationCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9121,8 +9227,7 @@ const deserializeAws_json1_1GetOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9147,10 +9252,12 @@ const deserializeAws_json1_1GetOperationsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9182,8 +9289,7 @@ const deserializeAws_json1_1GetOperationsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9208,10 +9314,12 @@ const deserializeAws_json1_1GetOperationsForResourceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9243,8 +9351,7 @@ const deserializeAws_json1_1GetRegionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9269,10 +9376,12 @@ const deserializeAws_json1_1GetRegionsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9304,8 +9413,7 @@ const deserializeAws_json1_1GetRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9330,10 +9438,12 @@ const deserializeAws_json1_1GetRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9365,8 +9475,7 @@ const deserializeAws_json1_1GetRelationalDatabaseBlueprintsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9391,10 +9500,12 @@ const deserializeAws_json1_1GetRelationalDatabaseBlueprintsCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9426,8 +9537,7 @@ const deserializeAws_json1_1GetRelationalDatabaseBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9452,10 +9562,12 @@ const deserializeAws_json1_1GetRelationalDatabaseBundlesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9487,8 +9599,7 @@ const deserializeAws_json1_1GetRelationalDatabaseEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9513,10 +9624,12 @@ const deserializeAws_json1_1GetRelationalDatabaseEventsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9548,8 +9661,7 @@ const deserializeAws_json1_1GetRelationalDatabaseLogEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9574,10 +9686,12 @@ const deserializeAws_json1_1GetRelationalDatabaseLogEventsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9609,8 +9723,7 @@ const deserializeAws_json1_1GetRelationalDatabaseLogStreamsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9635,10 +9748,12 @@ const deserializeAws_json1_1GetRelationalDatabaseLogStreamsCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9670,8 +9785,7 @@ const deserializeAws_json1_1GetRelationalDatabaseMasterUserPasswordCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9696,10 +9810,12 @@ const deserializeAws_json1_1GetRelationalDatabaseMasterUserPasswordCommandError throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9731,8 +9847,7 @@ const deserializeAws_json1_1GetRelationalDatabaseMetricDataCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9757,10 +9872,12 @@ const deserializeAws_json1_1GetRelationalDatabaseMetricDataCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9792,8 +9909,7 @@ const deserializeAws_json1_1GetRelationalDatabaseParametersCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9818,10 +9934,12 @@ const deserializeAws_json1_1GetRelationalDatabaseParametersCommandError = async throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9853,8 +9971,7 @@ const deserializeAws_json1_1GetRelationalDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9879,10 +9996,12 @@ const deserializeAws_json1_1GetRelationalDatabasesCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9914,8 +10033,7 @@ const deserializeAws_json1_1GetRelationalDatabaseSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -9940,10 +10058,12 @@ const deserializeAws_json1_1GetRelationalDatabaseSnapshotCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9975,8 +10095,7 @@ const deserializeAws_json1_1GetRelationalDatabaseSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10001,10 +10120,12 @@ const deserializeAws_json1_1GetRelationalDatabaseSnapshotsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10036,8 +10157,7 @@ const deserializeAws_json1_1GetStaticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10062,10 +10182,12 @@ const deserializeAws_json1_1GetStaticIpCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10097,8 +10219,7 @@ const deserializeAws_json1_1GetStaticIpsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10123,10 +10244,12 @@ const deserializeAws_json1_1GetStaticIpsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10158,8 +10281,7 @@ const deserializeAws_json1_1ImportKeyPairCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10184,10 +10306,12 @@ const deserializeAws_json1_1ImportKeyPairCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10219,8 +10343,7 @@ const deserializeAws_json1_1IsVpcPeeredCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10245,10 +10368,12 @@ const deserializeAws_json1_1IsVpcPeeredCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10280,8 +10405,7 @@ const deserializeAws_json1_1OpenInstancePublicPortsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10306,10 +10430,12 @@ const deserializeAws_json1_1OpenInstancePublicPortsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10341,8 +10467,7 @@ const deserializeAws_json1_1PeerVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10367,10 +10492,12 @@ const deserializeAws_json1_1PeerVpcCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10402,8 +10529,7 @@ const deserializeAws_json1_1PutAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10425,10 +10551,12 @@ const deserializeAws_json1_1PutAlarmCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10460,8 +10588,7 @@ const deserializeAws_json1_1PutInstancePublicPortsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10486,10 +10613,12 @@ const deserializeAws_json1_1PutInstancePublicPortsCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10521,8 +10650,7 @@ const deserializeAws_json1_1RebootInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10547,10 +10675,12 @@ const deserializeAws_json1_1RebootInstanceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10582,8 +10712,7 @@ const deserializeAws_json1_1RebootRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10608,10 +10737,12 @@ const deserializeAws_json1_1RebootRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10643,8 +10774,7 @@ const deserializeAws_json1_1RegisterContainerImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10663,10 +10793,12 @@ const deserializeAws_json1_1RegisterContainerImageCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10698,8 +10830,7 @@ const deserializeAws_json1_1ReleaseStaticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10724,10 +10855,12 @@ const deserializeAws_json1_1ReleaseStaticIpCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10759,8 +10892,7 @@ const deserializeAws_json1_1ResetDistributionCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10782,10 +10914,12 @@ const deserializeAws_json1_1ResetDistributionCacheCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10817,8 +10951,7 @@ const deserializeAws_json1_1SendContactMethodVerificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10840,10 +10973,12 @@ const deserializeAws_json1_1SendContactMethodVerificationCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10875,8 +11010,7 @@ const deserializeAws_json1_1SetIpAddressTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10901,10 +11035,12 @@ const deserializeAws_json1_1SetIpAddressTypeCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10936,8 +11072,7 @@ const deserializeAws_json1_1SetResourceAccessForBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -10956,10 +11091,12 @@ const deserializeAws_json1_1SetResourceAccessForBucketCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10991,8 +11128,7 @@ const deserializeAws_json1_1StartInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11017,10 +11153,12 @@ const deserializeAws_json1_1StartInstanceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11052,8 +11190,7 @@ const deserializeAws_json1_1StartRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11078,10 +11215,12 @@ const deserializeAws_json1_1StartRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11113,8 +11252,7 @@ const deserializeAws_json1_1StopInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11139,10 +11277,12 @@ const deserializeAws_json1_1StopInstanceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11174,8 +11314,7 @@ const deserializeAws_json1_1StopRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11200,10 +11339,12 @@ const deserializeAws_json1_1StopRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11235,8 +11376,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11261,10 +11401,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11296,8 +11438,7 @@ const deserializeAws_json1_1TestAlarmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11319,10 +11460,12 @@ const deserializeAws_json1_1TestAlarmCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11354,8 +11497,7 @@ const deserializeAws_json1_1UnpeerVpcCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11380,10 +11522,12 @@ const deserializeAws_json1_1UnpeerVpcCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11415,8 +11559,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11441,10 +11584,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11476,8 +11621,7 @@ const deserializeAws_json1_1UpdateBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11496,10 +11640,12 @@ const deserializeAws_json1_1UpdateBucketCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11531,8 +11677,7 @@ const deserializeAws_json1_1UpdateBucketBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11551,10 +11696,12 @@ const deserializeAws_json1_1UpdateBucketBundleCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11586,8 +11733,7 @@ const deserializeAws_json1_1UpdateContainerServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11606,10 +11752,12 @@ const deserializeAws_json1_1UpdateContainerServiceCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11641,8 +11789,7 @@ const deserializeAws_json1_1UpdateDistributionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11664,10 +11811,12 @@ const deserializeAws_json1_1UpdateDistributionCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11699,8 +11848,7 @@ const deserializeAws_json1_1UpdateDistributionBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11722,10 +11870,12 @@ const deserializeAws_json1_1UpdateDistributionBundleCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11757,8 +11907,7 @@ const deserializeAws_json1_1UpdateDomainEntryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11783,10 +11932,12 @@ const deserializeAws_json1_1UpdateDomainEntryCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11818,8 +11969,7 @@ const deserializeAws_json1_1UpdateLoadBalancerAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11844,10 +11994,12 @@ const deserializeAws_json1_1UpdateLoadBalancerAttributeCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11879,8 +12031,7 @@ const deserializeAws_json1_1UpdateRelationalDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11905,10 +12056,12 @@ const deserializeAws_json1_1UpdateRelationalDatabaseCommandError = async ( throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11940,8 +12093,7 @@ const deserializeAws_json1_1UpdateRelationalDatabaseParametersCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lightsail#AccessDeniedException": @@ -11966,10 +12118,12 @@ const deserializeAws_json1_1UpdateRelationalDatabaseParametersCommandError = asy throw await deserializeAws_json1_1UnauthenticatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18784,7 +18938,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -18810,6 +18964,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-location/src/protocols/Aws_restJson1.ts b/clients/client-location/src/protocols/Aws_restJson1.ts index e07a6123db6eb..2fa2844e7b961 100644 --- a/clients/client-location/src/protocols/Aws_restJson1.ts +++ b/clients/client-location/src/protocols/Aws_restJson1.ts @@ -2440,8 +2440,7 @@ const deserializeAws_restJson1AssociateTrackerConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2466,10 +2465,12 @@ const deserializeAws_restJson1AssociateTrackerConsumerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2502,8 +2503,7 @@ const deserializeAws_restJson1BatchDeleteDevicePositionHistoryCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2522,10 +2522,12 @@ const deserializeAws_restJson1BatchDeleteDevicePositionHistoryCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2558,8 +2560,7 @@ const deserializeAws_restJson1BatchDeleteGeofenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2578,10 +2579,12 @@ const deserializeAws_restJson1BatchDeleteGeofenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2614,8 +2617,7 @@ const deserializeAws_restJson1BatchEvaluateGeofencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2634,10 +2636,12 @@ const deserializeAws_restJson1BatchEvaluateGeofencesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2674,8 +2678,7 @@ const deserializeAws_restJson1BatchGetDevicePositionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2694,10 +2697,12 @@ const deserializeAws_restJson1BatchGetDevicePositionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2734,8 +2739,7 @@ const deserializeAws_restJson1BatchPutGeofenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2754,10 +2758,12 @@ const deserializeAws_restJson1BatchPutGeofenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2790,8 +2796,7 @@ const deserializeAws_restJson1BatchUpdateDevicePositionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2810,10 +2815,12 @@ const deserializeAws_restJson1BatchUpdateDevicePositionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2850,8 +2857,7 @@ const deserializeAws_restJson1CalculateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2870,10 +2876,12 @@ const deserializeAws_restJson1CalculateRouteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2921,8 +2929,7 @@ const deserializeAws_restJson1CalculateRouteMatrixCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -2941,10 +2948,12 @@ const deserializeAws_restJson1CalculateRouteMatrixCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2985,8 +2994,7 @@ const deserializeAws_restJson1CreateGeofenceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3005,10 +3013,12 @@ const deserializeAws_restJson1CreateGeofenceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3049,8 +3059,7 @@ const deserializeAws_restJson1CreateMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3069,10 +3078,12 @@ const deserializeAws_restJson1CreateMapCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3113,8 +3124,7 @@ const deserializeAws_restJson1CreatePlaceIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3133,10 +3143,12 @@ const deserializeAws_restJson1CreatePlaceIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3177,8 +3189,7 @@ const deserializeAws_restJson1CreateRouteCalculatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3197,10 +3208,12 @@ const deserializeAws_restJson1CreateRouteCalculatorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3241,8 +3254,7 @@ const deserializeAws_restJson1CreateTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3261,10 +3273,12 @@ const deserializeAws_restJson1CreateTrackerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3293,8 +3307,7 @@ const deserializeAws_restJson1DeleteGeofenceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3313,10 +3326,12 @@ const deserializeAws_restJson1DeleteGeofenceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3345,8 +3360,7 @@ const deserializeAws_restJson1DeleteMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3365,10 +3379,12 @@ const deserializeAws_restJson1DeleteMapCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3397,8 +3413,7 @@ const deserializeAws_restJson1DeletePlaceIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3417,10 +3432,12 @@ const deserializeAws_restJson1DeletePlaceIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3449,8 +3466,7 @@ const deserializeAws_restJson1DeleteRouteCalculatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3469,10 +3485,12 @@ const deserializeAws_restJson1DeleteRouteCalculatorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3501,8 +3519,7 @@ const deserializeAws_restJson1DeleteTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3521,10 +3538,12 @@ const deserializeAws_restJson1DeleteTrackerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3589,8 +3608,7 @@ const deserializeAws_restJson1DescribeGeofenceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3609,10 +3627,12 @@ const deserializeAws_restJson1DescribeGeofenceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3677,8 +3697,7 @@ const deserializeAws_restJson1DescribeMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3697,10 +3716,12 @@ const deserializeAws_restJson1DescribeMapCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3768,8 +3789,7 @@ const deserializeAws_restJson1DescribePlaceIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3788,10 +3808,12 @@ const deserializeAws_restJson1DescribePlaceIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3852,8 +3874,7 @@ const deserializeAws_restJson1DescribeRouteCalculatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3872,10 +3893,12 @@ const deserializeAws_restJson1DescribeRouteCalculatorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3944,8 +3967,7 @@ const deserializeAws_restJson1DescribeTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -3964,10 +3986,12 @@ const deserializeAws_restJson1DescribeTrackerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3996,8 +4020,7 @@ const deserializeAws_restJson1DisassociateTrackerConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4016,10 +4039,12 @@ const deserializeAws_restJson1DisassociateTrackerConsumerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4072,8 +4097,7 @@ const deserializeAws_restJson1GetDevicePositionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4092,10 +4116,12 @@ const deserializeAws_restJson1GetDevicePositionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4132,8 +4158,7 @@ const deserializeAws_restJson1GetDevicePositionHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4152,10 +4177,12 @@ const deserializeAws_restJson1GetDevicePositionHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4204,8 +4231,7 @@ const deserializeAws_restJson1GetGeofenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4224,10 +4250,12 @@ const deserializeAws_restJson1GetGeofenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4262,8 +4290,7 @@ const deserializeAws_restJson1GetMapGlyphsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4282,10 +4309,12 @@ const deserializeAws_restJson1GetMapGlyphsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4320,8 +4349,7 @@ const deserializeAws_restJson1GetMapSpritesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4340,10 +4368,12 @@ const deserializeAws_restJson1GetMapSpritesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4378,8 +4408,7 @@ const deserializeAws_restJson1GetMapStyleDescriptorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4398,10 +4427,12 @@ const deserializeAws_restJson1GetMapStyleDescriptorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4436,8 +4467,7 @@ const deserializeAws_restJson1GetMapTileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4456,10 +4486,12 @@ const deserializeAws_restJson1GetMapTileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4496,8 +4528,7 @@ const deserializeAws_restJson1ListDevicePositionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4513,10 +4544,12 @@ const deserializeAws_restJson1ListDevicePositionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4553,8 +4586,7 @@ const deserializeAws_restJson1ListGeofenceCollectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4570,10 +4602,12 @@ const deserializeAws_restJson1ListGeofenceCollectionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4610,8 +4644,7 @@ const deserializeAws_restJson1ListGeofencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4630,10 +4663,12 @@ const deserializeAws_restJson1ListGeofencesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4670,8 +4705,7 @@ const deserializeAws_restJson1ListMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4687,10 +4721,12 @@ const deserializeAws_restJson1ListMapsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4727,8 +4763,7 @@ const deserializeAws_restJson1ListPlaceIndexesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4744,10 +4779,12 @@ const deserializeAws_restJson1ListPlaceIndexesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4784,8 +4821,7 @@ const deserializeAws_restJson1ListRouteCalculatorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4801,10 +4837,12 @@ const deserializeAws_restJson1ListRouteCalculatorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4837,8 +4875,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4857,10 +4894,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4897,8 +4936,7 @@ const deserializeAws_restJson1ListTrackerConsumersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4917,10 +4955,12 @@ const deserializeAws_restJson1ListTrackerConsumersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4957,8 +4997,7 @@ const deserializeAws_restJson1ListTrackersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -4974,10 +5013,12 @@ const deserializeAws_restJson1ListTrackersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5018,8 +5059,7 @@ const deserializeAws_restJson1PutGeofenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5041,10 +5081,12 @@ const deserializeAws_restJson1PutGeofenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5081,8 +5123,7 @@ const deserializeAws_restJson1SearchPlaceIndexForPositionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5101,10 +5142,12 @@ const deserializeAws_restJson1SearchPlaceIndexForPositionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5141,8 +5184,7 @@ const deserializeAws_restJson1SearchPlaceIndexForSuggestionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5161,10 +5203,12 @@ const deserializeAws_restJson1SearchPlaceIndexForSuggestionsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5201,8 +5245,7 @@ const deserializeAws_restJson1SearchPlaceIndexForTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5221,10 +5264,12 @@ const deserializeAws_restJson1SearchPlaceIndexForTextCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5253,8 +5298,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5273,10 +5317,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5305,8 +5351,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5325,10 +5370,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5369,8 +5416,7 @@ const deserializeAws_restJson1UpdateGeofenceCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5389,10 +5435,12 @@ const deserializeAws_restJson1UpdateGeofenceCollectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5433,8 +5481,7 @@ const deserializeAws_restJson1UpdateMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5453,10 +5500,12 @@ const deserializeAws_restJson1UpdateMapCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5497,8 +5546,7 @@ const deserializeAws_restJson1UpdatePlaceIndexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5517,10 +5565,12 @@ const deserializeAws_restJson1UpdatePlaceIndexCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5561,8 +5611,7 @@ const deserializeAws_restJson1UpdateRouteCalculatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5581,10 +5630,12 @@ const deserializeAws_restJson1UpdateRouteCalculatorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5625,8 +5676,7 @@ const deserializeAws_restJson1UpdateTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.location#AccessDeniedException": @@ -5645,10 +5695,12 @@ const deserializeAws_restJson1UpdateTrackerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7053,7 +7105,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7079,6 +7131,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lookoutequipment/src/protocols/Aws_json1_0.ts b/clients/client-lookoutequipment/src/protocols/Aws_json1_0.ts index 4d59596632e5f..e7682070359cf 100644 --- a/clients/client-lookoutequipment/src/protocols/Aws_json1_0.ts +++ b/clients/client-lookoutequipment/src/protocols/Aws_json1_0.ts @@ -513,8 +513,7 @@ const deserializeAws_json1_0CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -536,10 +535,12 @@ const deserializeAws_json1_0CreateDatasetCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -571,8 +572,7 @@ const deserializeAws_json1_0CreateInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -597,10 +597,12 @@ const deserializeAws_json1_0CreateInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -632,8 +634,7 @@ const deserializeAws_json1_0CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -658,10 +659,12 @@ const deserializeAws_json1_0CreateModelCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -690,8 +693,7 @@ const deserializeAws_json1_0DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -710,10 +712,12 @@ const deserializeAws_json1_0DeleteDatasetCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -742,8 +746,7 @@ const deserializeAws_json1_0DeleteInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -765,10 +768,12 @@ const deserializeAws_json1_0DeleteInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -797,8 +802,7 @@ const deserializeAws_json1_0DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -817,10 +821,12 @@ const deserializeAws_json1_0DeleteModelCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -852,8 +858,7 @@ const deserializeAws_json1_0DescribeDataIngestionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -872,10 +877,12 @@ const deserializeAws_json1_0DescribeDataIngestionJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -907,8 +914,7 @@ const deserializeAws_json1_0DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -927,10 +933,12 @@ const deserializeAws_json1_0DescribeDatasetCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -962,8 +970,7 @@ const deserializeAws_json1_0DescribeInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -982,10 +989,12 @@ const deserializeAws_json1_0DescribeInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1017,8 +1026,7 @@ const deserializeAws_json1_0DescribeModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1037,10 +1045,12 @@ const deserializeAws_json1_0DescribeModelCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1072,8 +1082,7 @@ const deserializeAws_json1_0ListDataIngestionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1089,10 +1098,12 @@ const deserializeAws_json1_0ListDataIngestionJobsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1124,8 +1135,7 @@ const deserializeAws_json1_0ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1141,10 +1151,12 @@ const deserializeAws_json1_0ListDatasetsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1176,8 +1188,7 @@ const deserializeAws_json1_0ListInferenceEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1196,10 +1207,12 @@ const deserializeAws_json1_0ListInferenceEventsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1231,8 +1244,7 @@ const deserializeAws_json1_0ListInferenceExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1251,10 +1263,12 @@ const deserializeAws_json1_0ListInferenceExecutionsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1286,8 +1300,7 @@ const deserializeAws_json1_0ListInferenceSchedulersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1303,10 +1316,12 @@ const deserializeAws_json1_0ListInferenceSchedulersCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1338,8 +1353,7 @@ const deserializeAws_json1_0ListModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1355,10 +1369,12 @@ const deserializeAws_json1_0ListModelsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1390,8 +1406,7 @@ const deserializeAws_json1_0ListSensorStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1410,10 +1425,12 @@ const deserializeAws_json1_0ListSensorStatisticsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1445,8 +1462,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1465,10 +1481,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1500,8 +1518,7 @@ const deserializeAws_json1_0StartDataIngestionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1526,10 +1543,12 @@ const deserializeAws_json1_0StartDataIngestionJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1561,8 +1580,7 @@ const deserializeAws_json1_0StartInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1584,10 +1602,12 @@ const deserializeAws_json1_0StartInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1619,8 +1639,7 @@ const deserializeAws_json1_0StopInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1642,10 +1661,12 @@ const deserializeAws_json1_0StopInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,8 +1698,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1700,10 +1720,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1735,8 +1757,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1755,10 +1776,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1787,8 +1810,7 @@ const deserializeAws_json1_0UpdateInferenceSchedulerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutequipment#AccessDeniedException": @@ -1810,10 +1832,12 @@ const deserializeAws_json1_0UpdateInferenceSchedulerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3381,7 +3405,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3407,6 +3431,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lookoutmetrics/src/protocols/Aws_restJson1.ts b/clients/client-lookoutmetrics/src/protocols/Aws_restJson1.ts index e98fa0edcf872..c0506a5ac167b 100644 --- a/clients/client-lookoutmetrics/src/protocols/Aws_restJson1.ts +++ b/clients/client-lookoutmetrics/src/protocols/Aws_restJson1.ts @@ -1040,8 +1040,7 @@ const deserializeAws_restJson1ActivateAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1063,10 +1062,12 @@ const deserializeAws_restJson1ActivateAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1095,8 +1096,7 @@ const deserializeAws_restJson1BackTestAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1115,10 +1115,12 @@ const deserializeAws_restJson1BackTestAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1151,8 +1153,7 @@ const deserializeAws_restJson1CreateAlertCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1177,10 +1178,12 @@ const deserializeAws_restJson1CreateAlertCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1213,8 +1216,7 @@ const deserializeAws_restJson1CreateAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1236,10 +1238,12 @@ const deserializeAws_restJson1CreateAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1272,8 +1276,7 @@ const deserializeAws_restJson1CreateMetricSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1298,10 +1301,12 @@ const deserializeAws_restJson1CreateMetricSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1330,8 +1335,7 @@ const deserializeAws_restJson1DeactivateAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1353,10 +1357,12 @@ const deserializeAws_restJson1DeactivateAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1385,8 +1391,7 @@ const deserializeAws_restJson1DeleteAlertCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1405,10 +1410,12 @@ const deserializeAws_restJson1DeleteAlertCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1437,8 +1444,7 @@ const deserializeAws_restJson1DeleteAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1460,10 +1466,12 @@ const deserializeAws_restJson1DeleteAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1496,8 +1504,7 @@ const deserializeAws_restJson1DescribeAlertCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1516,10 +1523,12 @@ const deserializeAws_restJson1DescribeAlertCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1556,8 +1565,7 @@ const deserializeAws_restJson1DescribeAnomalyDetectionExecutionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1576,10 +1584,12 @@ const deserializeAws_restJson1DescribeAnomalyDetectionExecutionsCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1651,8 +1661,7 @@ const deserializeAws_restJson1DescribeAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1671,10 +1680,12 @@ const deserializeAws_restJson1DescribeAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1755,8 +1766,7 @@ const deserializeAws_restJson1DescribeMetricSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1775,10 +1785,12 @@ const deserializeAws_restJson1DescribeMetricSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1826,7 @@ const deserializeAws_restJson1DetectMetricSetConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1834,10 +1845,12 @@ const deserializeAws_restJson1DetectMetricSetConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1870,8 +1883,7 @@ const deserializeAws_restJson1GetAnomalyGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1890,10 +1902,12 @@ const deserializeAws_restJson1GetAnomalyGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1933,8 +1947,7 @@ const deserializeAws_restJson1GetFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -1953,10 +1966,12 @@ const deserializeAws_restJson1GetFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1993,8 +2008,7 @@ const deserializeAws_restJson1GetSampleDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2013,10 +2027,12 @@ const deserializeAws_restJson1GetSampleDataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2053,8 +2069,7 @@ const deserializeAws_restJson1ListAlertsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2073,10 +2088,12 @@ const deserializeAws_restJson1ListAlertsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2116,8 +2133,7 @@ const deserializeAws_restJson1ListAnomalyDetectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2136,10 +2152,12 @@ const deserializeAws_restJson1ListAnomalyDetectorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2176,8 +2194,7 @@ const deserializeAws_restJson1ListAnomalyGroupRelatedMetricsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2196,10 +2213,12 @@ const deserializeAws_restJson1ListAnomalyGroupRelatedMetricsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2246,8 +2265,7 @@ const deserializeAws_restJson1ListAnomalyGroupSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2266,10 +2284,12 @@ const deserializeAws_restJson1ListAnomalyGroupSummariesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2318,8 +2338,7 @@ const deserializeAws_restJson1ListAnomalyGroupTimeSeriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2338,10 +2357,12 @@ const deserializeAws_restJson1ListAnomalyGroupTimeSeriesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2378,8 +2399,7 @@ const deserializeAws_restJson1ListMetricSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2398,10 +2418,12 @@ const deserializeAws_restJson1ListMetricSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2434,8 +2456,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lookoutmetrics#InternalServerException": @@ -2448,10 +2469,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2503,7 @@ const deserializeAws_restJson1PutFeedbackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2500,10 +2522,12 @@ const deserializeAws_restJson1PutFeedbackCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2532,8 +2556,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lookoutmetrics#InternalServerException": @@ -2546,10 +2569,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2578,8 +2603,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.lookoutmetrics#InternalServerException": @@ -2592,10 +2616,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2628,8 +2654,7 @@ const deserializeAws_restJson1UpdateAlertCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2648,10 +2673,12 @@ const deserializeAws_restJson1UpdateAlertCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2684,8 +2711,7 @@ const deserializeAws_restJson1UpdateAnomalyDetectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2704,10 +2730,12 @@ const deserializeAws_restJson1UpdateAnomalyDetectorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2740,8 +2768,7 @@ const deserializeAws_restJson1UpdateMetricSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutmetrics#AccessDeniedException": @@ -2763,10 +2790,12 @@ const deserializeAws_restJson1UpdateMetricSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4413,7 +4442,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4439,6 +4468,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-lookoutvision/src/protocols/Aws_restJson1.ts b/clients/client-lookoutvision/src/protocols/Aws_restJson1.ts index 58d387ae54dd1..c5f2b105bfefc 100644 --- a/clients/client-lookoutvision/src/protocols/Aws_restJson1.ts +++ b/clients/client-lookoutvision/src/protocols/Aws_restJson1.ts @@ -945,8 +945,7 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -971,10 +970,12 @@ const deserializeAws_restJson1CreateDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1007,8 +1008,7 @@ const deserializeAws_restJson1CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1033,10 +1033,12 @@ const deserializeAws_restJson1CreateModelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1069,8 +1071,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1095,10 +1096,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1127,8 +1130,7 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1150,10 +1152,12 @@ const deserializeAws_restJson1DeleteDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1186,8 +1190,7 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1209,10 +1212,12 @@ const deserializeAws_restJson1DeleteModelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1245,8 +1250,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1268,10 +1272,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,8 +1310,7 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1327,10 +1332,12 @@ const deserializeAws_restJson1DescribeDatasetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1363,8 +1370,7 @@ const deserializeAws_restJson1DescribeModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1386,10 +1392,12 @@ const deserializeAws_restJson1DescribeModelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1425,8 +1433,7 @@ const deserializeAws_restJson1DescribeModelPackagingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1445,10 +1452,12 @@ const deserializeAws_restJson1DescribeModelPackagingJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1481,8 +1490,7 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1504,10 +1512,12 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1540,8 +1550,7 @@ const deserializeAws_restJson1DetectAnomaliesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1563,10 +1572,12 @@ const deserializeAws_restJson1DetectAnomaliesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1614,7 @@ const deserializeAws_restJson1ListDatasetEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1626,10 +1636,12 @@ const deserializeAws_restJson1ListDatasetEntriesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1666,8 +1678,7 @@ const deserializeAws_restJson1ListModelPackagingJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1686,10 +1697,12 @@ const deserializeAws_restJson1ListModelPackagingJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1726,8 +1739,7 @@ const deserializeAws_restJson1ListModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1749,10 +1761,12 @@ const deserializeAws_restJson1ListModelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1789,8 +1803,7 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1812,10 +1825,12 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1848,8 +1863,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1871,10 +1885,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1907,8 +1923,7 @@ const deserializeAws_restJson1StartModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1933,10 +1948,12 @@ const deserializeAws_restJson1StartModelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1969,8 +1986,7 @@ const deserializeAws_restJson1StartModelPackagingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -1995,10 +2011,12 @@ const deserializeAws_restJson1StartModelPackagingJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2031,8 +2049,7 @@ const deserializeAws_restJson1StopModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -2054,10 +2071,12 @@ const deserializeAws_restJson1StopModelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2086,8 +2105,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -2112,10 +2130,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2144,8 +2164,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -2167,10 +2186,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2203,8 +2224,7 @@ const deserializeAws_restJson1UpdateDatasetEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.lookoutvision#AccessDeniedException": @@ -2226,10 +2246,12 @@ const deserializeAws_restJson1UpdateDatasetEntriesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2898,7 +2920,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2924,6 +2946,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-m2/src/protocols/Aws_restJson1.ts b/clients/client-m2/src/protocols/Aws_restJson1.ts index aaddadd5fd21c..9953d7f31f767 100644 --- a/clients/client-m2/src/protocols/Aws_restJson1.ts +++ b/clients/client-m2/src/protocols/Aws_restJson1.ts @@ -1273,8 +1273,7 @@ const deserializeAws_restJson1CancelBatchJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1296,10 +1295,12 @@ const deserializeAws_restJson1CancelBatchJobExecutionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1340,8 +1341,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1363,10 +1363,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1399,8 +1401,7 @@ const deserializeAws_restJson1CreateDataSetImportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1425,10 +1426,12 @@ const deserializeAws_restJson1CreateDataSetImportTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1461,8 +1464,7 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1487,10 +1489,12 @@ const deserializeAws_restJson1CreateDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1523,8 +1527,7 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1546,10 +1549,12 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1578,8 +1583,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1598,10 +1602,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1630,8 +1636,7 @@ const deserializeAws_restJson1DeleteApplicationFromEnvironmentCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1653,10 +1658,12 @@ const deserializeAws_restJson1DeleteApplicationFromEnvironmentCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1685,8 +1692,7 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1705,10 +1711,12 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1809,8 +1817,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1829,10 +1836,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1889,8 +1898,7 @@ const deserializeAws_restJson1GetApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -1909,10 +1917,12 @@ const deserializeAws_restJson1GetApplicationVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1981,8 +1991,7 @@ const deserializeAws_restJson1GetBatchJobExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2001,10 +2010,12 @@ const deserializeAws_restJson1GetBatchJobExecutionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2065,8 +2076,7 @@ const deserializeAws_restJson1GetDataSetDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2085,10 +2095,12 @@ const deserializeAws_restJson1GetDataSetDetailsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2129,8 +2141,7 @@ const deserializeAws_restJson1GetDataSetImportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2149,10 +2160,12 @@ const deserializeAws_restJson1GetDataSetImportTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2209,8 +2222,7 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2229,10 +2241,12 @@ const deserializeAws_restJson1GetDeploymentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2351,8 +2365,7 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2371,10 +2384,12 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2411,8 +2426,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2428,10 +2442,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2471,8 +2487,7 @@ const deserializeAws_restJson1ListApplicationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2491,10 +2506,12 @@ const deserializeAws_restJson1ListApplicationVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2531,8 +2548,7 @@ const deserializeAws_restJson1ListBatchJobDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2551,10 +2567,12 @@ const deserializeAws_restJson1ListBatchJobDefinitionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2594,8 +2612,7 @@ const deserializeAws_restJson1ListBatchJobExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2614,10 +2631,12 @@ const deserializeAws_restJson1ListBatchJobExecutionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2654,8 +2673,7 @@ const deserializeAws_restJson1ListDataSetImportHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2674,10 +2692,12 @@ const deserializeAws_restJson1ListDataSetImportHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2714,8 +2734,7 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2734,10 +2753,12 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2774,8 +2795,7 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2794,10 +2814,12 @@ const deserializeAws_restJson1ListDeploymentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2834,8 +2856,7 @@ const deserializeAws_restJson1ListEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2851,10 +2872,12 @@ const deserializeAws_restJson1ListEngineVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2891,8 +2914,7 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2908,10 +2930,12 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2944,8 +2968,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -2964,10 +2987,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2996,8 +3021,7 @@ const deserializeAws_restJson1StartApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3019,10 +3043,12 @@ const deserializeAws_restJson1StartApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3055,8 +3081,7 @@ const deserializeAws_restJson1StartBatchJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3078,10 +3103,12 @@ const deserializeAws_restJson1StartBatchJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3110,8 +3137,7 @@ const deserializeAws_restJson1StopApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3133,10 +3159,12 @@ const deserializeAws_restJson1StopApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3165,8 +3193,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3188,10 +3215,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3220,8 +3249,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3240,10 +3268,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3276,8 +3306,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3299,10 +3328,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3335,8 +3366,7 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.m2#AccessDeniedException": @@ -3361,10 +3391,12 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4344,7 +4376,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4370,6 +4402,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-machine-learning/src/protocols/Aws_json1_1.ts b/clients/client-machine-learning/src/protocols/Aws_json1_1.ts index 856094ca1a4f7..1c459a1261b30 100644 --- a/clients/client-machine-learning/src/protocols/Aws_json1_1.ts +++ b/clients/client-machine-learning/src/protocols/Aws_json1_1.ts @@ -556,8 +556,7 @@ const deserializeAws_json1_1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -576,10 +575,12 @@ const deserializeAws_json1_1AddTagsCommandError = async ( throw await deserializeAws_json1_1TagLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -611,8 +612,7 @@ const deserializeAws_json1_1CreateBatchPredictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -625,10 +625,12 @@ const deserializeAws_json1_1CreateBatchPredictionCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -660,8 +662,7 @@ const deserializeAws_json1_1CreateDataSourceFromRDSCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -674,10 +675,12 @@ const deserializeAws_json1_1CreateDataSourceFromRDSCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -709,8 +712,7 @@ const deserializeAws_json1_1CreateDataSourceFromRedshiftCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -723,10 +725,12 @@ const deserializeAws_json1_1CreateDataSourceFromRedshiftCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -758,8 +762,7 @@ const deserializeAws_json1_1CreateDataSourceFromS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -772,10 +775,12 @@ const deserializeAws_json1_1CreateDataSourceFromS3CommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -807,8 +812,7 @@ const deserializeAws_json1_1CreateEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -821,10 +825,12 @@ const deserializeAws_json1_1CreateEvaluationCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -856,8 +862,7 @@ const deserializeAws_json1_1CreateMLModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.machinelearning#IdempotentParameterMismatchException": @@ -870,10 +875,12 @@ const deserializeAws_json1_1CreateMLModelCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -905,8 +912,7 @@ const deserializeAws_json1_1CreateRealtimeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -919,10 +925,12 @@ const deserializeAws_json1_1CreateRealtimeEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -954,8 +962,7 @@ const deserializeAws_json1_1DeleteBatchPredictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -968,10 +975,12 @@ const deserializeAws_json1_1DeleteBatchPredictionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1003,8 +1012,7 @@ const deserializeAws_json1_1DeleteDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1017,10 +1025,12 @@ const deserializeAws_json1_1DeleteDataSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1052,8 +1062,7 @@ const deserializeAws_json1_1DeleteEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1066,10 +1075,12 @@ const deserializeAws_json1_1DeleteEvaluationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1101,8 +1112,7 @@ const deserializeAws_json1_1DeleteMLModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1115,10 +1125,12 @@ const deserializeAws_json1_1DeleteMLModelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1150,8 +1162,7 @@ const deserializeAws_json1_1DeleteRealtimeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1164,10 +1175,12 @@ const deserializeAws_json1_1DeleteRealtimeEndpointCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1199,8 +1212,7 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1216,10 +1228,12 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1251,8 +1265,7 @@ const deserializeAws_json1_1DescribeBatchPredictionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1262,10 +1275,12 @@ const deserializeAws_json1_1DescribeBatchPredictionsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1297,8 +1312,7 @@ const deserializeAws_json1_1DescribeDataSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1308,10 +1322,12 @@ const deserializeAws_json1_1DescribeDataSourcesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1343,8 +1359,7 @@ const deserializeAws_json1_1DescribeEvaluationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1354,10 +1369,12 @@ const deserializeAws_json1_1DescribeEvaluationsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1389,8 +1406,7 @@ const deserializeAws_json1_1DescribeMLModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1400,10 +1416,12 @@ const deserializeAws_json1_1DescribeMLModelsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1435,8 +1453,7 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1449,10 +1466,12 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1484,8 +1503,7 @@ const deserializeAws_json1_1GetBatchPredictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1498,10 +1516,12 @@ const deserializeAws_json1_1GetBatchPredictionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1533,8 +1553,7 @@ const deserializeAws_json1_1GetDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1547,10 +1566,12 @@ const deserializeAws_json1_1GetDataSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1603,7 @@ const deserializeAws_json1_1GetEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1596,10 +1616,12 @@ const deserializeAws_json1_1GetEvaluationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1653,7 @@ const deserializeAws_json1_1GetMLModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1645,10 +1666,12 @@ const deserializeAws_json1_1GetMLModelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1680,8 +1703,7 @@ const deserializeAws_json1_1PredictCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1700,10 +1722,12 @@ const deserializeAws_json1_1PredictCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1735,8 +1759,7 @@ const deserializeAws_json1_1UpdateBatchPredictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1749,10 +1772,12 @@ const deserializeAws_json1_1UpdateBatchPredictionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1784,8 +1809,7 @@ const deserializeAws_json1_1UpdateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1798,10 +1822,12 @@ const deserializeAws_json1_1UpdateDataSourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1833,8 +1859,7 @@ const deserializeAws_json1_1UpdateEvaluationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1847,10 +1872,12 @@ const deserializeAws_json1_1UpdateEvaluationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1882,8 +1909,7 @@ const deserializeAws_json1_1UpdateMLModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.machinelearning#InternalServerException": @@ -1896,10 +1922,12 @@ const deserializeAws_json1_1UpdateMLModelCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3321,7 +3349,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3347,6 +3375,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-macie/src/protocols/Aws_json1_1.ts b/clients/client-macie/src/protocols/Aws_json1_1.ts index f0e7cfe45a2d8..9e52afc5c2ee9 100644 --- a/clients/client-macie/src/protocols/Aws_json1_1.ts +++ b/clients/client-macie/src/protocols/Aws_json1_1.ts @@ -171,8 +171,7 @@ const deserializeAws_json1_1AssociateMemberAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.macie#InternalException": @@ -185,10 +184,12 @@ const deserializeAws_json1_1AssociateMemberAccountCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -220,8 +221,7 @@ const deserializeAws_json1_1AssociateS3ResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie#AccessDeniedException": @@ -237,10 +237,12 @@ const deserializeAws_json1_1AssociateS3ResourcesCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -269,8 +271,7 @@ const deserializeAws_json1_1DisassociateMemberAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.macie#InternalException": @@ -280,10 +281,12 @@ const deserializeAws_json1_1DisassociateMemberAccountCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -315,8 +318,7 @@ const deserializeAws_json1_1DisassociateS3ResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie#AccessDeniedException": @@ -329,10 +331,12 @@ const deserializeAws_json1_1DisassociateS3ResourcesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -364,8 +368,7 @@ const deserializeAws_json1_1ListMemberAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.macie#InternalException": @@ -375,10 +378,12 @@ const deserializeAws_json1_1ListMemberAccountsCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -410,8 +415,7 @@ const deserializeAws_json1_1ListS3ResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie#AccessDeniedException": @@ -424,10 +428,12 @@ const deserializeAws_json1_1ListS3ResourcesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -459,8 +465,7 @@ const deserializeAws_json1_1UpdateS3ResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie#AccessDeniedException": @@ -473,10 +478,12 @@ const deserializeAws_json1_1UpdateS3ResourcesCommandError = async ( throw await deserializeAws_json1_1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -934,7 +941,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -960,6 +967,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-macie2/src/protocols/Aws_restJson1.ts b/clients/client-macie2/src/protocols/Aws_restJson1.ts index cc38901241920..f7a68f88c5f15 100644 --- a/clients/client-macie2/src/protocols/Aws_restJson1.ts +++ b/clients/client-macie2/src/protocols/Aws_restJson1.ts @@ -1923,8 +1923,7 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -1949,10 +1948,12 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1992,8 +1993,7 @@ const deserializeAws_restJson1BatchGetCustomDataIdentifiersCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2018,10 +2018,12 @@ const deserializeAws_restJson1BatchGetCustomDataIdentifiersCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2058,8 +2060,7 @@ const deserializeAws_restJson1CreateClassificationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2084,10 +2085,12 @@ const deserializeAws_restJson1CreateClassificationJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2120,8 +2123,7 @@ const deserializeAws_restJson1CreateCustomDataIdentifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2146,10 +2148,12 @@ const deserializeAws_restJson1CreateCustomDataIdentifierCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2186,8 +2190,7 @@ const deserializeAws_restJson1CreateFindingsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2212,10 +2215,12 @@ const deserializeAws_restJson1CreateFindingsFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2251,8 +2256,7 @@ const deserializeAws_restJson1CreateInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2277,10 +2281,12 @@ const deserializeAws_restJson1CreateInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2313,8 +2319,7 @@ const deserializeAws_restJson1CreateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2339,10 +2344,12 @@ const deserializeAws_restJson1CreateMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2371,8 +2378,7 @@ const deserializeAws_restJson1CreateSampleFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2397,10 +2403,12 @@ const deserializeAws_restJson1CreateSampleFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2436,8 +2444,7 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2462,10 +2469,12 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2494,8 +2503,7 @@ const deserializeAws_restJson1DeleteCustomDataIdentifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2520,10 +2528,12 @@ const deserializeAws_restJson1DeleteCustomDataIdentifierCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2552,8 +2562,7 @@ const deserializeAws_restJson1DeleteFindingsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2578,10 +2587,12 @@ const deserializeAws_restJson1DeleteFindingsFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2617,8 +2628,7 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2643,10 +2653,12 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2675,8 +2687,7 @@ const deserializeAws_restJson1DeleteMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2701,10 +2712,12 @@ const deserializeAws_restJson1DeleteMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2741,8 +2754,7 @@ const deserializeAws_restJson1DescribeBucketsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2767,10 +2779,12 @@ const deserializeAws_restJson1DescribeBucketsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2882,8 +2896,7 @@ const deserializeAws_restJson1DescribeClassificationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2908,10 +2921,12 @@ const deserializeAws_restJson1DescribeClassificationJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2948,8 +2963,7 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -2974,10 +2988,12 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3006,8 +3022,7 @@ const deserializeAws_restJson1DisableMacieCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3032,10 +3047,12 @@ const deserializeAws_restJson1DisableMacieCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3064,8 +3081,7 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3090,10 +3106,12 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3122,8 +3140,7 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3148,10 +3165,12 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3180,8 +3199,7 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3206,10 +3224,12 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3238,8 +3258,7 @@ const deserializeAws_restJson1DisassociateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3264,10 +3283,12 @@ const deserializeAws_restJson1DisassociateMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3296,8 +3317,7 @@ const deserializeAws_restJson1EnableMacieCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3322,10 +3342,12 @@ const deserializeAws_restJson1EnableMacieCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3354,8 +3376,7 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3380,10 +3401,12 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3416,8 +3439,7 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3442,10 +3464,12 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3548,8 +3572,7 @@ const deserializeAws_restJson1GetBucketStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3574,10 +3597,12 @@ const deserializeAws_restJson1GetBucketStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3610,8 +3635,7 @@ const deserializeAws_restJson1GetClassificationExportConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3636,10 +3660,12 @@ const deserializeAws_restJson1GetClassificationExportConfigurationCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3716,8 +3742,7 @@ const deserializeAws_restJson1GetCustomDataIdentifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3742,10 +3767,12 @@ const deserializeAws_restJson1GetCustomDataIdentifierCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3778,8 +3805,7 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3804,10 +3830,12 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3868,8 +3896,7 @@ const deserializeAws_restJson1GetFindingsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3894,10 +3921,12 @@ const deserializeAws_restJson1GetFindingsFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3933,8 +3962,7 @@ const deserializeAws_restJson1GetFindingsPublicationConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -3959,10 +3987,12 @@ const deserializeAws_restJson1GetFindingsPublicationConfigurationCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3995,8 +4025,7 @@ const deserializeAws_restJson1GetFindingStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4021,10 +4050,12 @@ const deserializeAws_restJson1GetFindingStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4057,8 +4088,7 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4083,10 +4113,12 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4135,8 +4167,7 @@ const deserializeAws_restJson1GetMacieSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4161,10 +4192,12 @@ const deserializeAws_restJson1GetMacieSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4197,8 +4230,7 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4223,10 +4255,12 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4291,8 +4325,7 @@ const deserializeAws_restJson1GetMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4317,10 +4350,12 @@ const deserializeAws_restJson1GetMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4361,8 +4396,7 @@ const deserializeAws_restJson1GetUsageStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4387,10 +4421,12 @@ const deserializeAws_restJson1GetUsageStatisticsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4427,8 +4463,7 @@ const deserializeAws_restJson1GetUsageTotalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4453,10 +4488,12 @@ const deserializeAws_restJson1GetUsageTotalsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4493,8 +4530,7 @@ const deserializeAws_restJson1ListClassificationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4519,10 +4555,12 @@ const deserializeAws_restJson1ListClassificationJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4559,8 +4597,7 @@ const deserializeAws_restJson1ListCustomDataIdentifiersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4585,10 +4622,12 @@ const deserializeAws_restJson1ListCustomDataIdentifiersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4625,8 +4664,7 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4651,10 +4689,12 @@ const deserializeAws_restJson1ListFindingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4694,8 +4734,7 @@ const deserializeAws_restJson1ListFindingsFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4720,10 +4759,12 @@ const deserializeAws_restJson1ListFindingsFiltersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4760,8 +4801,7 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4786,10 +4826,12 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4826,15 +4868,16 @@ const deserializeAws_restJson1ListManagedDataIdentifiersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4871,8 +4914,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4897,10 +4939,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4937,8 +4981,7 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -4963,10 +5006,12 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4999,15 +5044,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5040,8 +5086,7 @@ const deserializeAws_restJson1PutClassificationExportConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5066,10 +5111,12 @@ const deserializeAws_restJson1PutClassificationExportConfigurationCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5098,8 +5145,7 @@ const deserializeAws_restJson1PutFindingsPublicationConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5124,10 +5170,12 @@ const deserializeAws_restJson1PutFindingsPublicationConfigurationCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5164,8 +5212,7 @@ const deserializeAws_restJson1SearchResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5190,10 +5237,12 @@ const deserializeAws_restJson1SearchResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5222,15 +5271,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5263,8 +5313,7 @@ const deserializeAws_restJson1TestCustomDataIdentifierCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5289,10 +5338,12 @@ const deserializeAws_restJson1TestCustomDataIdentifierCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5321,15 +5372,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5358,8 +5410,7 @@ const deserializeAws_restJson1UpdateClassificationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5384,10 +5435,12 @@ const deserializeAws_restJson1UpdateClassificationJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5424,8 +5477,7 @@ const deserializeAws_restJson1UpdateFindingsFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5450,10 +5502,12 @@ const deserializeAws_restJson1UpdateFindingsFilterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5482,8 +5536,7 @@ const deserializeAws_restJson1UpdateMacieSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5508,10 +5561,12 @@ const deserializeAws_restJson1UpdateMacieSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5540,8 +5595,7 @@ const deserializeAws_restJson1UpdateMemberSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5566,10 +5620,12 @@ const deserializeAws_restJson1UpdateMemberSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5598,8 +5654,7 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.macie2#AccessDeniedException": @@ -5624,10 +5679,12 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8106,7 +8163,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8132,6 +8189,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-managedblockchain/src/protocols/Aws_restJson1.ts b/clients/client-managedblockchain/src/protocols/Aws_restJson1.ts index c131a1e422392..1807986e81946 100644 --- a/clients/client-managedblockchain/src/protocols/Aws_restJson1.ts +++ b/clients/client-managedblockchain/src/protocols/Aws_restJson1.ts @@ -979,8 +979,7 @@ const deserializeAws_restJson1CreateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1011,10 +1010,12 @@ const deserializeAws_restJson1CreateMemberCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1051,8 +1052,7 @@ const deserializeAws_restJson1CreateNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1077,10 +1077,12 @@ const deserializeAws_restJson1CreateNetworkCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1113,8 +1115,7 @@ const deserializeAws_restJson1CreateNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1145,10 +1146,12 @@ const deserializeAws_restJson1CreateNodeCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1181,8 +1184,7 @@ const deserializeAws_restJson1CreateProposalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1207,10 +1209,12 @@ const deserializeAws_restJson1CreateProposalCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1239,8 +1243,7 @@ const deserializeAws_restJson1DeleteMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1262,10 +1265,12 @@ const deserializeAws_restJson1DeleteMemberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1294,8 +1299,7 @@ const deserializeAws_restJson1DeleteNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1317,10 +1321,12 @@ const deserializeAws_restJson1DeleteNodeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1353,8 +1359,7 @@ const deserializeAws_restJson1GetMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1373,10 +1378,12 @@ const deserializeAws_restJson1GetMemberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1409,8 +1416,7 @@ const deserializeAws_restJson1GetNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1429,10 +1435,12 @@ const deserializeAws_restJson1GetNetworkCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1465,8 +1473,7 @@ const deserializeAws_restJson1GetNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1485,10 +1492,12 @@ const deserializeAws_restJson1GetNodeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1530,7 @@ const deserializeAws_restJson1GetProposalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1541,10 +1549,12 @@ const deserializeAws_restJson1GetProposalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1581,8 +1591,7 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1604,10 +1613,12 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1644,8 +1655,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1661,10 +1671,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1701,8 +1713,7 @@ const deserializeAws_restJson1ListNetworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1718,10 +1729,12 @@ const deserializeAws_restJson1ListNetworksCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1758,8 +1771,7 @@ const deserializeAws_restJson1ListNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1775,10 +1787,12 @@ const deserializeAws_restJson1ListNodesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1815,8 +1829,7 @@ const deserializeAws_restJson1ListProposalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1835,10 +1848,12 @@ const deserializeAws_restJson1ListProposalsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1875,8 +1890,7 @@ const deserializeAws_restJson1ListProposalVotesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -1892,10 +1906,12 @@ const deserializeAws_restJson1ListProposalVotesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1928,8 +1944,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.managedblockchain#InternalServiceErrorException": @@ -1945,10 +1960,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1994,7 @@ const deserializeAws_restJson1RejectInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -2000,10 +2016,12 @@ const deserializeAws_restJson1RejectInvitationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2032,8 +2050,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.managedblockchain#InternalServiceErrorException": @@ -2052,10 +2069,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2084,8 +2103,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.managedblockchain#InternalServiceErrorException": @@ -2101,10 +2119,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotReadyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2153,7 @@ const deserializeAws_restJson1UpdateMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -2153,10 +2172,12 @@ const deserializeAws_restJson1UpdateMemberCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2185,8 +2206,7 @@ const deserializeAws_restJson1UpdateNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -2205,10 +2225,12 @@ const deserializeAws_restJson1UpdateNodeCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2237,8 +2259,7 @@ const deserializeAws_restJson1VoteOnProposalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.managedblockchain#AccessDeniedException": @@ -2260,10 +2281,12 @@ const deserializeAws_restJson1VoteOnProposalCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3206,7 +3229,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3232,6 +3255,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-marketplace-catalog/src/protocols/Aws_restJson1.ts b/clients/client-marketplace-catalog/src/protocols/Aws_restJson1.ts index f19717affb365..8389c82e6cf24 100644 --- a/clients/client-marketplace-catalog/src/protocols/Aws_restJson1.ts +++ b/clients/client-marketplace-catalog/src/protocols/Aws_restJson1.ts @@ -230,8 +230,7 @@ const deserializeAws_restJson1CancelChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -253,10 +252,12 @@ const deserializeAws_restJson1CancelChangeSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -321,8 +322,7 @@ const deserializeAws_restJson1DescribeChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -341,10 +341,12 @@ const deserializeAws_restJson1DescribeChangeSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -393,8 +395,7 @@ const deserializeAws_restJson1DescribeEntityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -416,10 +417,12 @@ const deserializeAws_restJson1DescribeEntityCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -456,8 +459,7 @@ const deserializeAws_restJson1ListChangeSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -473,10 +475,12 @@ const deserializeAws_restJson1ListChangeSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -513,8 +517,7 @@ const deserializeAws_restJson1ListEntitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -533,10 +536,12 @@ const deserializeAws_restJson1ListEntitiesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -573,8 +578,7 @@ const deserializeAws_restJson1StartChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.marketplacecatalog#AccessDeniedException": @@ -599,10 +603,12 @@ const deserializeAws_restJson1StartChangeSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -961,7 +967,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -987,6 +993,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-marketplace-commerce-analytics/src/protocols/Aws_json1_1.ts b/clients/client-marketplace-commerce-analytics/src/protocols/Aws_json1_1.ts index cf43a7a53bf74..38d61bc2e445a 100644 --- a/clients/client-marketplace-commerce-analytics/src/protocols/Aws_json1_1.ts +++ b/clients/client-marketplace-commerce-analytics/src/protocols/Aws_json1_1.ts @@ -77,18 +77,19 @@ const deserializeAws_json1_1GenerateDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "MarketplaceCommerceAnalyticsException": case "com.amazonaws.marketplacecommerceanalytics#MarketplaceCommerceAnalyticsException": throw await deserializeAws_json1_1MarketplaceCommerceAnalyticsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -120,18 +121,19 @@ const deserializeAws_json1_1StartSupportDataExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "MarketplaceCommerceAnalyticsException": case "com.amazonaws.marketplacecommerceanalytics#MarketplaceCommerceAnalyticsException": throw await deserializeAws_json1_1MarketplaceCommerceAnalyticsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -282,7 +284,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -308,6 +310,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-marketplace-entitlement-service/src/protocols/Aws_json1_1.ts b/clients/client-marketplace-entitlement-service/src/protocols/Aws_json1_1.ts index 5af7b090b4fe1..67bae7013a9ba 100644 --- a/clients/client-marketplace-entitlement-service/src/protocols/Aws_json1_1.ts +++ b/clients/client-marketplace-entitlement-service/src/protocols/Aws_json1_1.ts @@ -70,8 +70,7 @@ const deserializeAws_json1_1GetEntitlementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.marketplaceentitlementservice#InternalServiceErrorException": @@ -84,10 +83,12 @@ const deserializeAws_json1_1GetEntitlementsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -301,7 +302,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -327,6 +328,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-marketplace-metering/src/protocols/Aws_json1_1.ts b/clients/client-marketplace-metering/src/protocols/Aws_json1_1.ts index bef34fd1d69f9..d7ac0670a0997 100644 --- a/clients/client-marketplace-metering/src/protocols/Aws_json1_1.ts +++ b/clients/client-marketplace-metering/src/protocols/Aws_json1_1.ts @@ -130,8 +130,7 @@ const deserializeAws_json1_1BatchMeterUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledApiException": case "com.amazonaws.marketplacemetering#DisabledApiException": @@ -162,10 +161,12 @@ const deserializeAws_json1_1BatchMeterUsageCommandError = async ( throw await deserializeAws_json1_1TimestampOutOfBoundsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -197,8 +198,7 @@ const deserializeAws_json1_1MeterUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomerNotEntitledException": case "com.amazonaws.marketplacemetering#CustomerNotEntitledException": @@ -232,10 +232,12 @@ const deserializeAws_json1_1MeterUsageCommandError = async ( throw await deserializeAws_json1_1TimestampOutOfBoundsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -267,8 +269,7 @@ const deserializeAws_json1_1RegisterUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomerNotEntitledException": case "com.amazonaws.marketplacemetering#CustomerNotEntitledException": @@ -296,10 +297,12 @@ const deserializeAws_json1_1RegisterUsageCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -331,8 +334,7 @@ const deserializeAws_json1_1ResolveCustomerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledApiException": case "com.amazonaws.marketplacemetering#DisabledApiException": @@ -351,10 +353,12 @@ const deserializeAws_json1_1ResolveCustomerCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1005,7 +1009,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1031,6 +1035,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediaconnect/src/protocols/Aws_restJson1.ts b/clients/client-mediaconnect/src/protocols/Aws_restJson1.ts index e81d7134764b9..c2c2a4513885f 100644 --- a/clients/client-mediaconnect/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediaconnect/src/protocols/Aws_restJson1.ts @@ -1269,8 +1269,7 @@ const deserializeAws_restJson1AddFlowMediaStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1292,10 +1291,12 @@ const deserializeAws_restJson1AddFlowMediaStreamsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1332,8 +1333,7 @@ const deserializeAws_restJson1AddFlowOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AddFlowOutputs420Exception": case "com.amazonaws.mediaconnect#AddFlowOutputs420Exception": @@ -1358,10 +1358,12 @@ const deserializeAws_restJson1AddFlowOutputsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1398,8 +1400,7 @@ const deserializeAws_restJson1AddFlowSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1421,10 +1422,12 @@ const deserializeAws_restJson1AddFlowSourcesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1461,8 +1464,7 @@ const deserializeAws_restJson1AddFlowVpcInterfacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1484,10 +1486,12 @@ const deserializeAws_restJson1AddFlowVpcInterfacesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1520,8 +1524,7 @@ const deserializeAws_restJson1CreateFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1543,10 +1546,12 @@ const deserializeAws_restJson1CreateFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1583,8 +1588,7 @@ const deserializeAws_restJson1DeleteFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1606,10 +1610,12 @@ const deserializeAws_restJson1DeleteFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1646,8 +1652,7 @@ const deserializeAws_restJson1DescribeFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1669,10 +1674,12 @@ const deserializeAws_restJson1DescribeFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1705,8 +1712,7 @@ const deserializeAws_restJson1DescribeOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1725,10 +1731,12 @@ const deserializeAws_restJson1DescribeOfferingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1761,8 +1769,7 @@ const deserializeAws_restJson1DescribeReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1781,10 +1788,12 @@ const deserializeAws_restJson1DescribeReservationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1821,8 +1830,7 @@ const deserializeAws_restJson1GrantFlowEntitlementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1847,10 +1855,12 @@ const deserializeAws_restJson1GrantFlowEntitlementsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1887,8 +1897,7 @@ const deserializeAws_restJson1ListEntitlementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1904,10 +1913,12 @@ const deserializeAws_restJson1ListEntitlementsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1944,8 +1955,7 @@ const deserializeAws_restJson1ListFlowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -1961,10 +1971,12 @@ const deserializeAws_restJson1ListFlowsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2001,8 +2013,7 @@ const deserializeAws_restJson1ListOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2018,10 +2029,12 @@ const deserializeAws_restJson1ListOfferingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2058,8 +2071,7 @@ const deserializeAws_restJson1ListReservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2075,10 +2087,12 @@ const deserializeAws_restJson1ListReservationsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2111,8 +2125,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2125,10 +2138,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2161,8 +2176,7 @@ const deserializeAws_restJson1PurchaseOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2184,10 +2198,12 @@ const deserializeAws_restJson1PurchaseOfferingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2224,8 +2240,7 @@ const deserializeAws_restJson1RemoveFlowMediaStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2247,10 +2262,12 @@ const deserializeAws_restJson1RemoveFlowMediaStreamCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2287,8 +2304,7 @@ const deserializeAws_restJson1RemoveFlowOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2310,10 +2326,12 @@ const deserializeAws_restJson1RemoveFlowOutputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2350,8 +2368,7 @@ const deserializeAws_restJson1RemoveFlowSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2373,10 +2390,12 @@ const deserializeAws_restJson1RemoveFlowSourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2420,8 +2439,7 @@ const deserializeAws_restJson1RemoveFlowVpcInterfaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2443,10 +2461,12 @@ const deserializeAws_restJson1RemoveFlowVpcInterfaceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2483,8 +2503,7 @@ const deserializeAws_restJson1RevokeFlowEntitlementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2506,10 +2525,12 @@ const deserializeAws_restJson1RevokeFlowEntitlementCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2546,8 +2567,7 @@ const deserializeAws_restJson1StartFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2569,10 +2589,12 @@ const deserializeAws_restJson1StartFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2609,8 +2631,7 @@ const deserializeAws_restJson1StopFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2632,10 +2653,12 @@ const deserializeAws_restJson1StopFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2664,8 +2687,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2678,10 +2700,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2710,8 +2734,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2724,10 +2747,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2760,8 +2785,7 @@ const deserializeAws_restJson1UpdateFlowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2783,10 +2807,12 @@ const deserializeAws_restJson1UpdateFlowCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2823,8 +2849,7 @@ const deserializeAws_restJson1UpdateFlowEntitlementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2846,10 +2871,12 @@ const deserializeAws_restJson1UpdateFlowEntitlementCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2886,8 +2913,7 @@ const deserializeAws_restJson1UpdateFlowMediaStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2909,10 +2935,12 @@ const deserializeAws_restJson1UpdateFlowMediaStreamCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2949,8 +2977,7 @@ const deserializeAws_restJson1UpdateFlowOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -2972,10 +2999,12 @@ const deserializeAws_restJson1UpdateFlowOutputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3012,8 +3041,7 @@ const deserializeAws_restJson1UpdateFlowSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconnect#BadRequestException": @@ -3035,10 +3063,12 @@ const deserializeAws_restJson1UpdateFlowSourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4278,7 +4308,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4304,6 +4334,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediaconvert/src/protocols/Aws_restJson1.ts b/clients/client-mediaconvert/src/protocols/Aws_restJson1.ts index cf067d1059685..24c9d2363da6d 100644 --- a/clients/client-mediaconvert/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediaconvert/src/protocols/Aws_restJson1.ts @@ -1120,8 +1120,7 @@ const deserializeAws_restJson1AssociateCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1143,10 +1142,12 @@ const deserializeAws_restJson1AssociateCertificateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1175,8 +1176,7 @@ const deserializeAws_restJson1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1198,10 +1198,12 @@ const deserializeAws_restJson1CancelJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1234,8 +1236,7 @@ const deserializeAws_restJson1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1257,10 +1258,12 @@ const deserializeAws_restJson1CreateJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1293,8 +1296,7 @@ const deserializeAws_restJson1CreateJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1316,10 +1318,12 @@ const deserializeAws_restJson1CreateJobTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1352,8 +1356,7 @@ const deserializeAws_restJson1CreatePresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1375,10 +1378,12 @@ const deserializeAws_restJson1CreatePresetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1411,8 +1416,7 @@ const deserializeAws_restJson1CreateQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1434,10 +1438,12 @@ const deserializeAws_restJson1CreateQueueCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1466,8 +1472,7 @@ const deserializeAws_restJson1DeleteJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1489,10 +1494,12 @@ const deserializeAws_restJson1DeleteJobTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1528,7 @@ const deserializeAws_restJson1DeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1544,10 +1550,12 @@ const deserializeAws_restJson1DeletePolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1576,8 +1584,7 @@ const deserializeAws_restJson1DeletePresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1599,10 +1606,12 @@ const deserializeAws_restJson1DeletePresetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1640,7 @@ const deserializeAws_restJson1DeleteQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1654,10 +1662,12 @@ const deserializeAws_restJson1DeleteQueueCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1704,7 @@ const deserializeAws_restJson1DescribeEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1717,10 +1726,12 @@ const deserializeAws_restJson1DescribeEndpointsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1749,8 +1760,7 @@ const deserializeAws_restJson1DisassociateCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1772,10 +1782,12 @@ const deserializeAws_restJson1DisassociateCertificateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1808,8 +1820,7 @@ const deserializeAws_restJson1GetJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1831,10 +1842,12 @@ const deserializeAws_restJson1GetJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1867,8 +1880,7 @@ const deserializeAws_restJson1GetJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1890,10 +1902,12 @@ const deserializeAws_restJson1GetJobTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1926,8 +1940,7 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -1949,10 +1962,12 @@ const deserializeAws_restJson1GetPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1985,8 +2000,7 @@ const deserializeAws_restJson1GetPresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2008,10 +2022,12 @@ const deserializeAws_restJson1GetPresetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,8 +2060,7 @@ const deserializeAws_restJson1GetQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2067,10 +2082,12 @@ const deserializeAws_restJson1GetQueueCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2107,8 +2124,7 @@ const deserializeAws_restJson1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2130,10 +2146,12 @@ const deserializeAws_restJson1ListJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2170,8 +2188,7 @@ const deserializeAws_restJson1ListJobTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2193,10 +2210,12 @@ const deserializeAws_restJson1ListJobTemplatesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2233,8 +2252,7 @@ const deserializeAws_restJson1ListPresetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2256,10 +2274,12 @@ const deserializeAws_restJson1ListPresetsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2296,8 +2316,7 @@ const deserializeAws_restJson1ListQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2319,10 +2338,12 @@ const deserializeAws_restJson1ListQueuesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2355,8 +2376,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2378,10 +2398,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2414,8 +2436,7 @@ const deserializeAws_restJson1PutPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2437,10 +2458,12 @@ const deserializeAws_restJson1PutPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2469,8 +2492,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2492,10 +2514,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2524,8 +2548,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2547,10 +2570,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2583,8 +2608,7 @@ const deserializeAws_restJson1UpdateJobTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2606,10 +2630,12 @@ const deserializeAws_restJson1UpdateJobTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2642,8 +2668,7 @@ const deserializeAws_restJson1UpdatePresetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2665,10 +2690,12 @@ const deserializeAws_restJson1UpdatePresetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2701,8 +2728,7 @@ const deserializeAws_restJson1UpdateQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediaconvert#BadRequestException": @@ -2724,10 +2750,12 @@ const deserializeAws_restJson1UpdateQueueCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9678,7 +9706,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9704,6 +9732,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-medialive/src/protocols/Aws_restJson1.ts b/clients/client-medialive/src/protocols/Aws_restJson1.ts index 8667e0a87633f..dc14751528e8b 100644 --- a/clients/client-medialive/src/protocols/Aws_restJson1.ts +++ b/clients/client-medialive/src/protocols/Aws_restJson1.ts @@ -2301,8 +2301,7 @@ const deserializeAws_restJson1AcceptInputDeviceTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2333,10 +2332,12 @@ const deserializeAws_restJson1AcceptInputDeviceTransferCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2373,8 +2374,7 @@ const deserializeAws_restJson1BatchDeleteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2402,10 +2402,12 @@ const deserializeAws_restJson1BatchDeleteCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2442,8 +2444,7 @@ const deserializeAws_restJson1BatchStartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2471,10 +2472,12 @@ const deserializeAws_restJson1BatchStartCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2511,8 +2514,7 @@ const deserializeAws_restJson1BatchStopCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2540,10 +2542,12 @@ const deserializeAws_restJson1BatchStopCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2580,8 +2584,7 @@ const deserializeAws_restJson1BatchUpdateScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2609,10 +2612,12 @@ const deserializeAws_restJson1BatchUpdateScheduleCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2641,8 +2646,7 @@ const deserializeAws_restJson1CancelInputDeviceTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2673,10 +2677,12 @@ const deserializeAws_restJson1CancelInputDeviceTransferCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2705,8 +2711,7 @@ const deserializeAws_restJson1ClaimDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2734,10 +2739,12 @@ const deserializeAws_restJson1ClaimDeviceCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2770,8 +2777,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2799,10 +2805,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2835,8 +2843,7 @@ const deserializeAws_restJson1CreateInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2858,10 +2865,12 @@ const deserializeAws_restJson1CreateInputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2894,8 +2903,7 @@ const deserializeAws_restJson1CreateInputSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2917,10 +2925,12 @@ const deserializeAws_restJson1CreateInputSecurityGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2953,8 +2963,7 @@ const deserializeAws_restJson1CreateMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -2982,10 +2991,12 @@ const deserializeAws_restJson1CreateMultiplexCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3018,8 +3029,7 @@ const deserializeAws_restJson1CreateMultiplexProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3047,10 +3057,12 @@ const deserializeAws_restJson1CreateMultiplexProgramCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3083,8 +3095,7 @@ const deserializeAws_restJson1CreatePartnerInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3106,10 +3117,12 @@ const deserializeAws_restJson1CreatePartnerInputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3138,8 +3151,7 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.medialive#BadRequestException": @@ -3155,10 +3167,12 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3259,8 +3273,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3288,10 +3301,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3320,8 +3335,7 @@ const deserializeAws_restJson1DeleteInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3349,10 +3363,12 @@ const deserializeAws_restJson1DeleteInputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3381,8 +3397,7 @@ const deserializeAws_restJson1DeleteInputSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3407,10 +3422,12 @@ const deserializeAws_restJson1DeleteInputSecurityGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3479,8 +3496,7 @@ const deserializeAws_restJson1DeleteMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3508,10 +3524,12 @@ const deserializeAws_restJson1DeleteMultiplexCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3569,8 +3587,7 @@ const deserializeAws_restJson1DeleteMultiplexProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3598,10 +3615,12 @@ const deserializeAws_restJson1DeleteMultiplexProgramCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3705,8 +3724,7 @@ const deserializeAws_restJson1DeleteReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3734,10 +3752,12 @@ const deserializeAws_restJson1DeleteReservationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3766,8 +3786,7 @@ const deserializeAws_restJson1DeleteScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3792,10 +3811,12 @@ const deserializeAws_restJson1DeleteScheduleCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3824,8 +3845,7 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.medialive#BadRequestException": @@ -3841,10 +3861,12 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3945,8 +3967,7 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -3971,10 +3992,12 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4067,8 +4090,7 @@ const deserializeAws_restJson1DescribeInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4093,10 +4115,12 @@ const deserializeAws_restJson1DescribeInputCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4173,8 +4197,7 @@ const deserializeAws_restJson1DescribeInputDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4199,10 +4222,12 @@ const deserializeAws_restJson1DescribeInputDeviceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4249,8 +4274,7 @@ const deserializeAws_restJson1DescribeInputDeviceThumbnailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4275,10 +4299,12 @@ const deserializeAws_restJson1DescribeInputDeviceThumbnailCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4331,8 +4357,7 @@ const deserializeAws_restJson1DescribeInputSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4357,10 +4382,12 @@ const deserializeAws_restJson1DescribeInputSecurityGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4429,8 +4456,7 @@ const deserializeAws_restJson1DescribeMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4455,10 +4481,12 @@ const deserializeAws_restJson1DescribeMultiplexCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4516,8 +4544,7 @@ const deserializeAws_restJson1DescribeMultiplexProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4542,10 +4569,12 @@ const deserializeAws_restJson1DescribeMultiplexProgramCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4621,8 +4650,7 @@ const deserializeAws_restJson1DescribeOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4647,10 +4675,12 @@ const deserializeAws_restJson1DescribeOfferingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4754,8 +4784,7 @@ const deserializeAws_restJson1DescribeReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4780,10 +4809,12 @@ const deserializeAws_restJson1DescribeReservationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4820,8 +4851,7 @@ const deserializeAws_restJson1DescribeScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4846,10 +4876,12 @@ const deserializeAws_restJson1DescribeScheduleCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4886,8 +4918,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4909,10 +4940,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4949,8 +4982,7 @@ const deserializeAws_restJson1ListInputDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -4972,10 +5004,12 @@ const deserializeAws_restJson1ListInputDevicesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5015,8 +5049,7 @@ const deserializeAws_restJson1ListInputDeviceTransfersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5041,10 +5074,12 @@ const deserializeAws_restJson1ListInputDeviceTransfersCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5081,8 +5116,7 @@ const deserializeAws_restJson1ListInputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5104,10 +5138,12 @@ const deserializeAws_restJson1ListInputsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5147,8 +5183,7 @@ const deserializeAws_restJson1ListInputSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5170,10 +5205,12 @@ const deserializeAws_restJson1ListInputSecurityGroupsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5210,8 +5247,7 @@ const deserializeAws_restJson1ListMultiplexesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5233,10 +5269,12 @@ const deserializeAws_restJson1ListMultiplexesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5276,8 +5314,7 @@ const deserializeAws_restJson1ListMultiplexProgramsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5302,10 +5339,12 @@ const deserializeAws_restJson1ListMultiplexProgramsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5342,8 +5381,7 @@ const deserializeAws_restJson1ListOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5365,10 +5403,12 @@ const deserializeAws_restJson1ListOfferingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5405,8 +5445,7 @@ const deserializeAws_restJson1ListReservationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5428,10 +5467,12 @@ const deserializeAws_restJson1ListReservationsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5464,8 +5505,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.medialive#BadRequestException": @@ -5481,10 +5521,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5517,8 +5559,7 @@ const deserializeAws_restJson1PurchaseOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5546,10 +5587,12 @@ const deserializeAws_restJson1PurchaseOfferingCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5578,8 +5621,7 @@ const deserializeAws_restJson1RejectInputDeviceTransferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5610,10 +5652,12 @@ const deserializeAws_restJson1RejectInputDeviceTransferCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5714,8 +5758,7 @@ const deserializeAws_restJson1StartChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5743,10 +5786,12 @@ const deserializeAws_restJson1StartChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5815,8 +5860,7 @@ const deserializeAws_restJson1StartMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5844,10 +5888,12 @@ const deserializeAws_restJson1StartMultiplexCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5948,8 +5994,7 @@ const deserializeAws_restJson1StopChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -5977,10 +6022,12 @@ const deserializeAws_restJson1StopChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6049,8 +6096,7 @@ const deserializeAws_restJson1StopMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6078,10 +6124,12 @@ const deserializeAws_restJson1StopMultiplexCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6110,8 +6158,7 @@ const deserializeAws_restJson1TransferInputDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6142,10 +6189,12 @@ const deserializeAws_restJson1TransferInputDeviceCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6178,8 +6227,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6204,10 +6252,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6240,8 +6290,7 @@ const deserializeAws_restJson1UpdateChannelClassCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6272,10 +6321,12 @@ const deserializeAws_restJson1UpdateChannelClassCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6308,8 +6359,7 @@ const deserializeAws_restJson1UpdateInputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6334,10 +6384,12 @@ const deserializeAws_restJson1UpdateInputCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6414,8 +6466,7 @@ const deserializeAws_restJson1UpdateInputDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6443,10 +6494,12 @@ const deserializeAws_restJson1UpdateInputDeviceCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6479,8 +6532,7 @@ const deserializeAws_restJson1UpdateInputSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6505,10 +6557,12 @@ const deserializeAws_restJson1UpdateInputSecurityGroupCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6541,8 +6595,7 @@ const deserializeAws_restJson1UpdateMultiplexCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6570,10 +6623,12 @@ const deserializeAws_restJson1UpdateMultiplexCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6606,8 +6661,7 @@ const deserializeAws_restJson1UpdateMultiplexProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6635,10 +6689,12 @@ const deserializeAws_restJson1UpdateMultiplexProgramCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6671,8 +6727,7 @@ const deserializeAws_restJson1UpdateReservationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadGatewayException": case "com.amazonaws.medialive#BadGatewayException": @@ -6700,10 +6755,12 @@ const deserializeAws_restJson1UpdateReservationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13830,7 +13887,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -13856,6 +13913,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediapackage-vod/src/protocols/Aws_restJson1.ts b/clients/client-mediapackage-vod/src/protocols/Aws_restJson1.ts index 0dd4c27863e97..3f38d17fa7580 100644 --- a/clients/client-mediapackage-vod/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediapackage-vod/src/protocols/Aws_restJson1.ts @@ -650,8 +650,7 @@ const deserializeAws_restJson1ConfigureLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -673,10 +672,12 @@ const deserializeAws_restJson1ConfigureLogsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -741,8 +742,7 @@ const deserializeAws_restJson1CreateAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -764,10 +764,12 @@ const deserializeAws_restJson1CreateAssetCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -828,8 +830,7 @@ const deserializeAws_restJson1CreatePackagingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -851,10 +852,12 @@ const deserializeAws_restJson1CreatePackagingConfigurationCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -907,8 +910,7 @@ const deserializeAws_restJson1CreatePackagingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -930,10 +932,12 @@ const deserializeAws_restJson1CreatePackagingGroupCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -962,8 +966,7 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -985,10 +988,12 @@ const deserializeAws_restJson1DeleteAssetCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1017,8 +1022,7 @@ const deserializeAws_restJson1DeletePackagingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1040,10 +1044,12 @@ const deserializeAws_restJson1DeletePackagingConfigurationCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1072,8 +1078,7 @@ const deserializeAws_restJson1DeletePackagingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1095,10 +1100,12 @@ const deserializeAws_restJson1DeletePackagingGroupCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1163,8 +1170,7 @@ const deserializeAws_restJson1DescribeAssetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1186,10 +1192,12 @@ const deserializeAws_restJson1DescribeAssetCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1250,8 +1258,7 @@ const deserializeAws_restJson1DescribePackagingConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1273,10 +1280,12 @@ const deserializeAws_restJson1DescribePackagingConfigurationCommandError = async throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1329,8 +1338,7 @@ const deserializeAws_restJson1DescribePackagingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1352,10 +1360,12 @@ const deserializeAws_restJson1DescribePackagingGroupCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1392,8 +1402,7 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1415,10 +1424,12 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1458,8 +1469,7 @@ const deserializeAws_restJson1ListPackagingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1481,10 +1491,12 @@ const deserializeAws_restJson1ListPackagingConfigurationsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1533,7 @@ const deserializeAws_restJson1ListPackagingGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1544,10 +1555,12 @@ const deserializeAws_restJson1ListPackagingGroupsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1580,15 +1593,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1617,15 +1631,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1654,15 +1669,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1715,8 +1731,7 @@ const deserializeAws_restJson1UpdatePackagingGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackagevod#ForbiddenException": @@ -1738,10 +1753,12 @@ const deserializeAws_restJson1UpdatePackagingGroupCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2544,7 +2561,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2570,6 +2587,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediapackage/src/protocols/Aws_restJson1.ts b/clients/client-mediapackage/src/protocols/Aws_restJson1.ts index 976d3e79e361b..4719ee9e92249 100644 --- a/clients/client-mediapackage/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediapackage/src/protocols/Aws_restJson1.ts @@ -757,8 +757,7 @@ const deserializeAws_restJson1ConfigureLogsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -780,10 +779,12 @@ const deserializeAws_restJson1ConfigureLogsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -840,8 +841,7 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -863,10 +863,12 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -931,8 +933,7 @@ const deserializeAws_restJson1CreateHarvestJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -954,10 +955,12 @@ const deserializeAws_restJson1CreateHarvestJobCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1050,8 +1053,7 @@ const deserializeAws_restJson1CreateOriginEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1073,10 +1075,12 @@ const deserializeAws_restJson1CreateOriginEndpointCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1105,8 +1109,7 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1128,10 +1131,12 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1165,7 @@ const deserializeAws_restJson1DeleteOriginEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1183,10 +1187,12 @@ const deserializeAws_restJson1DeleteOriginEndpointCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1249,7 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1266,10 +1271,12 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1334,8 +1341,7 @@ const deserializeAws_restJson1DescribeHarvestJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1357,10 +1363,12 @@ const deserializeAws_restJson1DescribeHarvestJobCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,8 +1461,7 @@ const deserializeAws_restJson1DescribeOriginEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1476,10 +1483,12 @@ const deserializeAws_restJson1DescribeOriginEndpointCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1516,8 +1525,7 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1539,10 +1547,12 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1579,8 +1589,7 @@ const deserializeAws_restJson1ListHarvestJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1602,10 +1611,12 @@ const deserializeAws_restJson1ListHarvestJobsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1642,8 +1653,7 @@ const deserializeAws_restJson1ListOriginEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1665,10 +1675,12 @@ const deserializeAws_restJson1ListOriginEndpointsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1701,15 +1713,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1766,8 +1779,7 @@ const deserializeAws_restJson1RotateChannelCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1789,10 +1801,12 @@ const deserializeAws_restJson1RotateChannelCredentialsCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1849,8 +1863,7 @@ const deserializeAws_restJson1RotateIngestEndpointCredentialsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -1872,10 +1885,12 @@ const deserializeAws_restJson1RotateIngestEndpointCredentialsCommandError = asyn throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1904,15 +1919,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1941,15 +1957,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2006,8 +2023,7 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -2029,10 +2045,12 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2125,8 +2143,7 @@ const deserializeAws_restJson1UpdateOriginEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ForbiddenException": case "com.amazonaws.mediapackage#ForbiddenException": @@ -2148,10 +2165,12 @@ const deserializeAws_restJson1UpdateOriginEndpointCommandError = async ( throw await deserializeAws_restJson1UnprocessableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3050,7 +3069,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3076,6 +3095,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts b/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts index 1b0b4feb50658..286e943527290 100644 --- a/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediastore-data/src/protocols/Aws_restJson1.ts @@ -230,8 +230,7 @@ const deserializeAws_restJson1DeleteObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastoredata#ContainerNotFoundException": @@ -244,10 +243,12 @@ const deserializeAws_restJson1DeleteObjectCommandError = async ( throw await deserializeAws_restJson1ObjectNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -296,8 +297,7 @@ const deserializeAws_restJson1DescribeObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastoredata#ContainerNotFoundException": @@ -310,10 +310,12 @@ const deserializeAws_restJson1DescribeObjectCommandError = async ( throw await deserializeAws_restJson1ObjectNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -372,8 +374,7 @@ const deserializeAws_restJson1GetObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastoredata#ContainerNotFoundException": @@ -389,10 +390,12 @@ const deserializeAws_restJson1GetObjectCommandError = async ( throw await deserializeAws_restJson1RequestedRangeNotSatisfiableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -429,8 +432,7 @@ const deserializeAws_restJson1ListItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastoredata#ContainerNotFoundException": @@ -440,10 +442,12 @@ const deserializeAws_restJson1ListItemsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -484,8 +488,7 @@ const deserializeAws_restJson1PutObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastoredata#ContainerNotFoundException": @@ -495,10 +498,12 @@ const deserializeAws_restJson1PutObjectCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -631,7 +636,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -657,6 +662,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediastore/src/protocols/Aws_json1_1.ts b/clients/client-mediastore/src/protocols/Aws_json1_1.ts index 0262422a24421..604af25277262 100644 --- a/clients/client-mediastore/src/protocols/Aws_json1_1.ts +++ b/clients/client-mediastore/src/protocols/Aws_json1_1.ts @@ -403,8 +403,7 @@ const deserializeAws_json1_1CreateContainerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -417,10 +416,12 @@ const deserializeAws_json1_1CreateContainerCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -452,8 +453,7 @@ const deserializeAws_json1_1DeleteContainerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -466,10 +466,12 @@ const deserializeAws_json1_1DeleteContainerCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -501,8 +503,7 @@ const deserializeAws_json1_1DeleteContainerPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -518,10 +519,12 @@ const deserializeAws_json1_1DeleteContainerPolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -553,8 +556,7 @@ const deserializeAws_json1_1DeleteCorsPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -570,10 +572,12 @@ const deserializeAws_json1_1DeleteCorsPolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -605,8 +609,7 @@ const deserializeAws_json1_1DeleteLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -622,10 +625,12 @@ const deserializeAws_json1_1DeleteLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -657,8 +662,7 @@ const deserializeAws_json1_1DeleteMetricPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -674,10 +678,12 @@ const deserializeAws_json1_1DeleteMetricPolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -709,8 +715,7 @@ const deserializeAws_json1_1DescribeContainerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerNotFoundException": case "com.amazonaws.mediastore#ContainerNotFoundException": @@ -720,10 +725,12 @@ const deserializeAws_json1_1DescribeContainerCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -755,8 +762,7 @@ const deserializeAws_json1_1GetContainerPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -772,10 +778,12 @@ const deserializeAws_json1_1GetContainerPolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -807,8 +815,7 @@ const deserializeAws_json1_1GetCorsPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -824,10 +831,12 @@ const deserializeAws_json1_1GetCorsPolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -859,8 +868,7 @@ const deserializeAws_json1_1GetLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -876,10 +884,12 @@ const deserializeAws_json1_1GetLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +921,7 @@ const deserializeAws_json1_1GetMetricPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -928,10 +937,12 @@ const deserializeAws_json1_1GetMetricPolicyCommandError = async ( throw await deserializeAws_json1_1PolicyNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -963,18 +974,19 @@ const deserializeAws_json1_1ListContainersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.mediastore#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1006,8 +1018,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1020,10 +1031,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1055,8 +1068,7 @@ const deserializeAws_json1_1PutContainerPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1069,10 +1081,12 @@ const deserializeAws_json1_1PutContainerPolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1104,8 +1118,7 @@ const deserializeAws_json1_1PutCorsPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1118,10 +1131,12 @@ const deserializeAws_json1_1PutCorsPolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1153,8 +1168,7 @@ const deserializeAws_json1_1PutLifecyclePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1167,10 +1181,12 @@ const deserializeAws_json1_1PutLifecyclePolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1202,8 +1218,7 @@ const deserializeAws_json1_1PutMetricPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1216,10 +1231,12 @@ const deserializeAws_json1_1PutMetricPolicyCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1251,8 +1268,7 @@ const deserializeAws_json1_1StartAccessLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1265,10 +1281,12 @@ const deserializeAws_json1_1StartAccessLoggingCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1318,7 @@ const deserializeAws_json1_1StopAccessLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1314,10 +1331,12 @@ const deserializeAws_json1_1StopAccessLoggingCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1368,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1363,10 +1381,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1398,8 +1418,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ContainerInUseException": case "com.amazonaws.mediastore#ContainerInUseException": @@ -1412,10 +1431,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2193,7 +2214,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2219,6 +2240,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mediatailor/src/protocols/Aws_restJson1.ts b/clients/client-mediatailor/src/protocols/Aws_restJson1.ts index 1c4d0c4a04cf5..4183d3a50f8ab 100644 --- a/clients/client-mediatailor/src/protocols/Aws_restJson1.ts +++ b/clients/client-mediatailor/src/protocols/Aws_restJson1.ts @@ -1739,15 +1739,16 @@ const deserializeAws_restJson1ConfigureLogsForPlaybackConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1816,15 +1817,16 @@ const deserializeAws_restJson1CreateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1884,15 +1886,16 @@ const deserializeAws_restJson1CreateLiveSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1945,15 +1948,16 @@ const deserializeAws_restJson1CreatePrefetchScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2018,15 +2022,16 @@ const deserializeAws_restJson1CreateProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2097,15 +2102,16 @@ const deserializeAws_restJson1CreateSourceLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2165,15 +2171,16 @@ const deserializeAws_restJson1CreateVodSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2202,15 +2209,16 @@ const deserializeAws_restJson1DeleteChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2239,15 +2247,16 @@ const deserializeAws_restJson1DeleteChannelPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2276,15 +2285,16 @@ const deserializeAws_restJson1DeleteLiveSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2313,15 +2323,16 @@ const deserializeAws_restJson1DeletePlaybackConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2350,15 +2361,16 @@ const deserializeAws_restJson1DeletePrefetchScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2387,15 +2399,16 @@ const deserializeAws_restJson1DeleteProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2424,15 +2437,16 @@ const deserializeAws_restJson1DeleteSourceLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2461,15 +2475,16 @@ const deserializeAws_restJson1DeleteVodSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2538,15 +2553,16 @@ const deserializeAws_restJson1DescribeChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2606,15 +2622,16 @@ const deserializeAws_restJson1DescribeLiveSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2679,15 +2696,16 @@ const deserializeAws_restJson1DescribeProgramCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2758,15 +2776,16 @@ const deserializeAws_restJson1DescribeSourceLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2826,15 +2845,16 @@ const deserializeAws_restJson1DescribeVodSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2867,15 +2887,16 @@ const deserializeAws_restJson1GetChannelPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2912,15 +2933,16 @@ const deserializeAws_restJson1GetChannelScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3034,15 +3056,16 @@ const deserializeAws_restJson1GetPlaybackConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3095,15 +3118,16 @@ const deserializeAws_restJson1GetPrefetchScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3140,15 +3164,16 @@ const deserializeAws_restJson1ListAlertsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3185,15 +3210,16 @@ const deserializeAws_restJson1ListChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3230,15 +3256,16 @@ const deserializeAws_restJson1ListLiveSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3275,15 +3302,16 @@ const deserializeAws_restJson1ListPlaybackConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3320,15 +3348,16 @@ const deserializeAws_restJson1ListPrefetchSchedulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3365,15 +3394,16 @@ const deserializeAws_restJson1ListSourceLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3406,18 +3436,19 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediatailor#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3454,15 +3485,16 @@ const deserializeAws_restJson1ListVodSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3491,15 +3523,16 @@ const deserializeAws_restJson1PutChannelPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3613,15 +3646,16 @@ const deserializeAws_restJson1PutPlaybackConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3650,15 +3684,16 @@ const deserializeAws_restJson1StartChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3687,15 +3722,16 @@ const deserializeAws_restJson1StopChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3724,18 +3760,19 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediatailor#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3764,18 +3801,19 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mediatailor#BadRequestException": throw await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3844,15 +3882,16 @@ const deserializeAws_restJson1UpdateChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3912,15 +3951,16 @@ const deserializeAws_restJson1UpdateLiveSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3991,15 +4031,16 @@ const deserializeAws_restJson1UpdateSourceLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4059,15 +4100,16 @@ const deserializeAws_restJson1UpdateVodSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5157,7 +5199,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5183,6 +5225,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-memorydb/src/protocols/Aws_json1_1.ts b/clients/client-memorydb/src/protocols/Aws_json1_1.ts index 0259a6b96df79..0465993402119 100644 --- a/clients/client-memorydb/src/protocols/Aws_json1_1.ts +++ b/clients/client-memorydb/src/protocols/Aws_json1_1.ts @@ -718,8 +718,7 @@ const deserializeAws_json1_1BatchUpdateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.memorydb#InvalidParameterValueException": @@ -729,10 +728,12 @@ const deserializeAws_json1_1BatchUpdateClusterCommandError = async ( throw await deserializeAws_json1_1ServiceUpdateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -764,8 +765,7 @@ const deserializeAws_json1_1CopySnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -793,10 +793,12 @@ const deserializeAws_json1_1CopySnapshotCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -828,8 +830,7 @@ const deserializeAws_json1_1CreateACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLAlreadyExistsFault": case "com.amazonaws.memorydb#ACLAlreadyExistsFault": @@ -854,10 +855,12 @@ const deserializeAws_json1_1CreateACLCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -889,8 +892,7 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -942,10 +944,12 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -977,8 +981,7 @@ const deserializeAws_json1_1CreateParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1003,10 +1006,12 @@ const deserializeAws_json1_1CreateParameterGroupCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1038,8 +1043,7 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.memorydb#ClusterNotFoundFault": @@ -1067,10 +1071,12 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1102,8 +1108,7 @@ const deserializeAws_json1_1CreateSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubnet": case "com.amazonaws.memorydb#InvalidSubnet": @@ -1128,10 +1133,12 @@ const deserializeAws_json1_1CreateSubnetGroupCommandError = async ( throw await deserializeAws_json1_1TagQuotaPerResourceExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1163,8 +1170,7 @@ const deserializeAws_json1_1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateUserNameFault": case "com.amazonaws.memorydb#DuplicateUserNameFault": @@ -1186,10 +1192,12 @@ const deserializeAws_json1_1CreateUserCommandError = async ( throw await deserializeAws_json1_1UserQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1221,8 +1229,7 @@ const deserializeAws_json1_1DeleteACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -1235,10 +1242,12 @@ const deserializeAws_json1_1DeleteACLCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1270,8 +1279,7 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.memorydb#ClusterNotFoundFault": @@ -1293,10 +1301,12 @@ const deserializeAws_json1_1DeleteClusterCommandError = async ( throw await deserializeAws_json1_1SnapshotAlreadyExistsFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1328,8 +1338,7 @@ const deserializeAws_json1_1DeleteParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1348,10 +1357,12 @@ const deserializeAws_json1_1DeleteParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1383,8 +1394,7 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1403,10 +1413,12 @@ const deserializeAws_json1_1DeleteSnapshotCommandError = async ( throw await deserializeAws_json1_1SnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1438,8 +1450,7 @@ const deserializeAws_json1_1DeleteSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceLinkedRoleNotFoundFault": case "com.amazonaws.memorydb#ServiceLinkedRoleNotFoundFault": @@ -1452,10 +1463,12 @@ const deserializeAws_json1_1DeleteSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1487,8 +1500,7 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValueException": case "com.amazonaws.memorydb#InvalidParameterValueException": @@ -1501,10 +1513,12 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1536,8 +1550,7 @@ const deserializeAws_json1_1DescribeACLsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -1547,10 +1560,12 @@ const deserializeAws_json1_1DescribeACLsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterCombinationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1597,7 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.memorydb#ClusterNotFoundFault": @@ -1599,10 +1613,12 @@ const deserializeAws_json1_1DescribeClustersCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1634,8 +1650,7 @@ const deserializeAws_json1_1DescribeEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1648,10 +1663,12 @@ const deserializeAws_json1_1DescribeEngineVersionsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1683,8 +1700,7 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1697,10 +1713,12 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1732,8 +1750,7 @@ const deserializeAws_json1_1DescribeParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1749,10 +1766,12 @@ const deserializeAws_json1_1DescribeParameterGroupsCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1784,8 +1803,7 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1801,10 +1819,12 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1836,8 +1856,7 @@ const deserializeAws_json1_1DescribeServiceUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1847,10 +1866,12 @@ const deserializeAws_json1_1DescribeServiceUpdatesCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValueExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1882,8 +1903,7 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1899,10 +1919,12 @@ const deserializeAws_json1_1DescribeSnapshotsCommandError = async ( throw await deserializeAws_json1_1SnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1934,8 +1956,7 @@ const deserializeAws_json1_1DescribeSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceLinkedRoleNotFoundFault": case "com.amazonaws.memorydb#ServiceLinkedRoleNotFoundFault": @@ -1945,10 +1966,12 @@ const deserializeAws_json1_1DescribeSubnetGroupsCommandError = async ( throw await deserializeAws_json1_1SubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1980,8 +2003,7 @@ const deserializeAws_json1_1DescribeUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -1991,10 +2013,12 @@ const deserializeAws_json1_1DescribeUsersCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2026,8 +2050,7 @@ const deserializeAws_json1_1FailoverShardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "APICallRateForCustomerExceededFault": case "com.amazonaws.memorydb#APICallRateForCustomerExceededFault": @@ -2055,10 +2078,12 @@ const deserializeAws_json1_1FailoverShardCommandError = async ( throw await deserializeAws_json1_1TestFailoverNotAvailableFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2090,8 +2115,7 @@ const deserializeAws_json1_1ListAllowedNodeTypeUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.memorydb#ClusterNotFoundFault": @@ -2107,10 +2131,12 @@ const deserializeAws_json1_1ListAllowedNodeTypeUpdatesCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2142,8 +2168,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -2174,10 +2199,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2209,8 +2236,7 @@ const deserializeAws_json1_1ResetParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -2229,10 +2255,12 @@ const deserializeAws_json1_1ResetParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2264,8 +2292,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -2299,10 +2326,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2334,8 +2363,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -2369,10 +2397,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2404,8 +2434,7 @@ const deserializeAws_json1_1UpdateACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -2430,10 +2459,12 @@ const deserializeAws_json1_1UpdateACLCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2465,8 +2496,7 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ACLNotFoundFault": case "com.amazonaws.memorydb#ACLNotFoundFault": @@ -2518,10 +2548,12 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( throw await deserializeAws_json1_1ShardsPerClusterQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2553,8 +2585,7 @@ const deserializeAws_json1_1UpdateParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -2573,10 +2604,12 @@ const deserializeAws_json1_1UpdateParameterGroupCommandError = async ( throw await deserializeAws_json1_1ServiceLinkedRoleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2608,8 +2641,7 @@ const deserializeAws_json1_1UpdateSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubnet": case "com.amazonaws.memorydb#InvalidSubnet": @@ -2631,10 +2663,12 @@ const deserializeAws_json1_1UpdateSubnetGroupCommandError = async ( throw await deserializeAws_json1_1SubnetQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2666,8 +2700,7 @@ const deserializeAws_json1_1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterCombinationException": case "com.amazonaws.memorydb#InvalidParameterCombinationException": @@ -2683,10 +2716,12 @@ const deserializeAws_json1_1UpdateUserCommandError = async ( throw await deserializeAws_json1_1UserNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5384,7 +5419,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5410,6 +5445,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mgn/src/protocols/Aws_restJson1.ts b/clients/client-mgn/src/protocols/Aws_restJson1.ts index f5ed62380ced7..09b65b46b1f2b 100644 --- a/clients/client-mgn/src/protocols/Aws_restJson1.ts +++ b/clients/client-mgn/src/protocols/Aws_restJson1.ts @@ -1278,8 +1278,7 @@ const deserializeAws_restJson1ChangeServerLifeCycleStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -1295,10 +1294,12 @@ const deserializeAws_restJson1ChangeServerLifeCycleStateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1343,8 +1344,7 @@ const deserializeAws_restJson1CreateLaunchConfigurationTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -1357,10 +1357,12 @@ const deserializeAws_restJson1CreateLaunchConfigurationTemplateCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1452,8 +1454,7 @@ const deserializeAws_restJson1CreateReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -1466,10 +1467,12 @@ const deserializeAws_restJson1CreateReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1498,8 +1501,7 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -1512,10 +1514,12 @@ const deserializeAws_restJson1DeleteJobCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1548,7 @@ const deserializeAws_restJson1DeleteLaunchConfigurationTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -1558,10 +1561,12 @@ const deserializeAws_restJson1DeleteLaunchConfigurationTemplateCommandError = as throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1590,8 +1595,7 @@ const deserializeAws_restJson1DeleteReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -1604,10 +1608,12 @@ const deserializeAws_restJson1DeleteReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1636,8 +1642,7 @@ const deserializeAws_restJson1DeleteSourceServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -1650,10 +1655,12 @@ const deserializeAws_restJson1DeleteSourceServerCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1682,8 +1689,7 @@ const deserializeAws_restJson1DeleteVcenterClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -1696,10 +1702,12 @@ const deserializeAws_restJson1DeleteVcenterClientCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1736,8 +1744,7 @@ const deserializeAws_restJson1DescribeJobLogItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UninitializedAccountException": case "com.amazonaws.mgn#UninitializedAccountException": @@ -1747,10 +1754,12 @@ const deserializeAws_restJson1DescribeJobLogItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1787,8 +1796,7 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UninitializedAccountException": case "com.amazonaws.mgn#UninitializedAccountException": @@ -1798,10 +1806,12 @@ const deserializeAws_restJson1DescribeJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1838,8 +1848,7 @@ const deserializeAws_restJson1DescribeLaunchConfigurationTemplatesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -1852,10 +1861,12 @@ const deserializeAws_restJson1DescribeLaunchConfigurationTemplatesCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1892,8 +1903,7 @@ const deserializeAws_restJson1DescribeReplicationConfigurationTemplatesCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -1906,10 +1916,12 @@ const deserializeAws_restJson1DescribeReplicationConfigurationTemplatesCommandEr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1946,8 +1958,7 @@ const deserializeAws_restJson1DescribeSourceServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UninitializedAccountException": case "com.amazonaws.mgn#UninitializedAccountException": @@ -1957,10 +1968,12 @@ const deserializeAws_restJson1DescribeSourceServersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1997,8 +2010,7 @@ const deserializeAws_restJson1DescribeVcenterClientsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -2011,10 +2023,12 @@ const deserializeAws_restJson1DescribeVcenterClientsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2083,8 +2097,7 @@ const deserializeAws_restJson1DisconnectFromServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2097,10 +2110,12 @@ const deserializeAws_restJson1DisconnectFromServiceCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2169,8 +2184,7 @@ const deserializeAws_restJson1FinalizeCutoverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2186,10 +2200,12 @@ const deserializeAws_restJson1FinalizeCutoverCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2258,8 +2274,7 @@ const deserializeAws_restJson1GetLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -2269,10 +2284,12 @@ const deserializeAws_restJson1GetLaunchConfigurationCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2367,8 +2384,7 @@ const deserializeAws_restJson1GetReplicationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -2378,10 +2394,12 @@ const deserializeAws_restJson1GetReplicationConfigurationCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2410,8 +2428,7 @@ const deserializeAws_restJson1InitializeServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -2421,10 +2438,12 @@ const deserializeAws_restJson1InitializeServiceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2457,8 +2476,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -2477,10 +2495,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2549,8 +2569,7 @@ const deserializeAws_restJson1MarkAsArchivedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2563,10 +2582,12 @@ const deserializeAws_restJson1MarkAsArchivedCommandError = async ( throw await deserializeAws_restJson1UninitializedAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2635,8 +2656,7 @@ const deserializeAws_restJson1RetryDataReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mgn#ResourceNotFoundException": @@ -2649,10 +2669,12 @@ const deserializeAws_restJson1RetryDataReplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2685,8 +2707,7 @@ const deserializeAws_restJson1StartCutoverCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2699,10 +2720,12 @@ const deserializeAws_restJson1StartCutoverCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2771,8 +2794,7 @@ const deserializeAws_restJson1StartReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2791,10 +2813,12 @@ const deserializeAws_restJson1StartReplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2827,8 +2851,7 @@ const deserializeAws_restJson1StartTestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2841,10 +2864,12 @@ const deserializeAws_restJson1StartTestCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2873,8 +2898,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -2893,10 +2917,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2929,8 +2955,7 @@ const deserializeAws_restJson1TerminateTargetInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -2943,10 +2968,12 @@ const deserializeAws_restJson1TerminateTargetInstancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2975,8 +3002,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -2995,10 +3021,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3067,8 +3095,7 @@ const deserializeAws_restJson1UpdateLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -3084,10 +3111,12 @@ const deserializeAws_restJson1UpdateLaunchConfigurationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3132,8 +3161,7 @@ const deserializeAws_restJson1UpdateLaunchConfigurationTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -3149,10 +3177,12 @@ const deserializeAws_restJson1UpdateLaunchConfigurationTemplateCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3247,8 +3277,7 @@ const deserializeAws_restJson1UpdateReplicationConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -3267,10 +3296,12 @@ const deserializeAws_restJson1UpdateReplicationConfigurationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3362,8 +3393,7 @@ const deserializeAws_restJson1UpdateReplicationConfigurationTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mgn#AccessDeniedException": @@ -3379,10 +3409,12 @@ const deserializeAws_restJson1UpdateReplicationConfigurationTemplateCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3451,8 +3483,7 @@ const deserializeAws_restJson1UpdateSourceServerReplicationTypeCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.mgn#ConflictException": @@ -3468,10 +3499,12 @@ const deserializeAws_restJson1UpdateSourceServerReplicationTypeCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4794,7 +4827,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4820,6 +4853,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-migration-hub-refactor-spaces/src/protocols/Aws_restJson1.ts b/clients/client-migration-hub-refactor-spaces/src/protocols/Aws_restJson1.ts index 2c9e9edfd5566..ade0960caa345 100644 --- a/clients/client-migration-hub-refactor-spaces/src/protocols/Aws_restJson1.ts +++ b/clients/client-migration-hub-refactor-spaces/src/protocols/Aws_restJson1.ts @@ -1081,8 +1081,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1107,10 +1106,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1179,8 +1180,7 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1205,10 +1205,12 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1285,8 +1287,7 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1311,10 +1312,12 @@ const deserializeAws_restJson1CreateRouteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1407,8 +1410,7 @@ const deserializeAws_restJson1CreateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1433,10 +1435,12 @@ const deserializeAws_restJson1CreateServiceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1489,8 +1493,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1512,10 +1515,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1564,8 +1569,7 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1587,10 +1591,12 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1619,8 +1625,7 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1639,10 +1644,12 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1695,8 +1702,7 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1718,10 +1724,12 @@ const deserializeAws_restJson1DeleteRouteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1778,8 +1786,7 @@ const deserializeAws_restJson1DeleteServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1801,10 +1808,12 @@ const deserializeAws_restJson1DeleteServiceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1889,8 +1898,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -1909,10 +1917,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1989,8 +1999,7 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2009,10 +2018,12 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2056,7 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2065,10 +2075,12 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2165,8 +2177,7 @@ const deserializeAws_restJson1GetRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2185,10 +2196,12 @@ const deserializeAws_restJson1GetRouteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2285,8 +2298,7 @@ const deserializeAws_restJson1GetServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2305,10 +2317,12 @@ const deserializeAws_restJson1GetServiceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2348,8 +2362,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2374,10 +2387,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2417,8 +2432,7 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2437,10 +2451,12 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2477,8 +2493,7 @@ const deserializeAws_restJson1ListEnvironmentVpcsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2497,10 +2512,12 @@ const deserializeAws_restJson1ListEnvironmentVpcsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2537,8 +2554,7 @@ const deserializeAws_restJson1ListRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2563,10 +2579,12 @@ const deserializeAws_restJson1ListRoutesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2603,8 +2621,7 @@ const deserializeAws_restJson1ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2629,10 +2646,12 @@ const deserializeAws_restJson1ListServicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2665,8 +2684,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubrefactorspaces#InternalServerException": @@ -2679,10 +2697,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2711,8 +2731,7 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2734,10 +2753,12 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2766,8 +2787,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubrefactorspaces#InternalServerException": @@ -2780,10 +2800,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2812,8 +2834,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubrefactorspaces#InternalServerException": @@ -2826,10 +2847,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2882,8 +2905,7 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubrefactorspaces#AccessDeniedException": @@ -2902,10 +2924,12 @@ const deserializeAws_restJson1UpdateRouteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3554,7 +3578,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3580,6 +3604,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-migration-hub/src/protocols/Aws_json1_1.ts b/clients/client-migration-hub/src/protocols/Aws_json1_1.ts index 81d604d2d11c9..2350fa59a90d7 100644 --- a/clients/client-migration-hub/src/protocols/Aws_json1_1.ts +++ b/clients/client-migration-hub/src/protocols/Aws_json1_1.ts @@ -383,8 +383,7 @@ const deserializeAws_json1_1AssociateCreatedArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -415,10 +414,12 @@ const deserializeAws_json1_1AssociateCreatedArtifactCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -450,8 +451,7 @@ const deserializeAws_json1_1AssociateDiscoveredResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -485,10 +485,12 @@ const deserializeAws_json1_1AssociateDiscoveredResourceCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -520,8 +522,7 @@ const deserializeAws_json1_1CreateProgressUpdateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -549,10 +550,12 @@ const deserializeAws_json1_1CreateProgressUpdateStreamCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -584,8 +587,7 @@ const deserializeAws_json1_1DeleteProgressUpdateStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -616,10 +618,12 @@ const deserializeAws_json1_1DeleteProgressUpdateStreamCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -651,8 +655,7 @@ const deserializeAws_json1_1DescribeApplicationStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -680,10 +683,12 @@ const deserializeAws_json1_1DescribeApplicationStateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -715,8 +720,7 @@ const deserializeAws_json1_1DescribeMigrationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -741,10 +745,12 @@ const deserializeAws_json1_1DescribeMigrationTaskCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -776,8 +782,7 @@ const deserializeAws_json1_1DisassociateCreatedArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -808,10 +813,12 @@ const deserializeAws_json1_1DisassociateCreatedArtifactCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -843,8 +850,7 @@ const deserializeAws_json1_1DisassociateDiscoveredResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -875,10 +881,12 @@ const deserializeAws_json1_1DisassociateDiscoveredResourceCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -910,8 +918,7 @@ const deserializeAws_json1_1ImportMigrationTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -942,10 +949,12 @@ const deserializeAws_json1_1ImportMigrationTaskCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -977,8 +986,7 @@ const deserializeAws_json1_1ListApplicationStatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1000,10 +1008,12 @@ const deserializeAws_json1_1ListApplicationStatesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1035,8 +1045,7 @@ const deserializeAws_json1_1ListCreatedArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1061,10 +1070,12 @@ const deserializeAws_json1_1ListCreatedArtifactsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1096,8 +1107,7 @@ const deserializeAws_json1_1ListDiscoveredResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1122,10 +1132,12 @@ const deserializeAws_json1_1ListDiscoveredResourcesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1157,8 +1169,7 @@ const deserializeAws_json1_1ListMigrationTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1186,10 +1197,12 @@ const deserializeAws_json1_1ListMigrationTasksCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1221,8 +1234,7 @@ const deserializeAws_json1_1ListProgressUpdateStreamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1244,10 +1256,12 @@ const deserializeAws_json1_1ListProgressUpdateStreamsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1279,8 +1293,7 @@ const deserializeAws_json1_1NotifyApplicationStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1314,10 +1327,12 @@ const deserializeAws_json1_1NotifyApplicationStateCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1364,7 @@ const deserializeAws_json1_1NotifyMigrationTaskStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1381,10 +1395,12 @@ const deserializeAws_json1_1NotifyMigrationTaskStateCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1416,8 +1432,7 @@ const deserializeAws_json1_1PutResourceAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhub#AccessDeniedException": @@ -1448,10 +1463,12 @@ const deserializeAws_json1_1PutResourceAttributesCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2317,7 +2334,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2343,6 +2360,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-migrationhub-config/src/protocols/Aws_json1_1.ts b/clients/client-migrationhub-config/src/protocols/Aws_json1_1.ts index 31fb11fe3eec0..5216971d1b330 100644 --- a/clients/client-migrationhub-config/src/protocols/Aws_json1_1.ts +++ b/clients/client-migrationhub-config/src/protocols/Aws_json1_1.ts @@ -107,8 +107,7 @@ const deserializeAws_json1_1CreateHomeRegionControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubconfig#AccessDeniedException": @@ -130,10 +129,12 @@ const deserializeAws_json1_1CreateHomeRegionControlCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -165,8 +166,7 @@ const deserializeAws_json1_1DescribeHomeRegionControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubconfig#AccessDeniedException": @@ -185,10 +185,12 @@ const deserializeAws_json1_1DescribeHomeRegionControlsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -220,8 +222,7 @@ const deserializeAws_json1_1GetHomeRegionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubconfig#AccessDeniedException": @@ -240,10 +241,12 @@ const deserializeAws_json1_1GetHomeRegionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -524,7 +527,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -550,6 +553,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-migrationhubstrategy/src/protocols/Aws_restJson1.ts b/clients/client-migrationhubstrategy/src/protocols/Aws_restJson1.ts index cb9c16e8bee2e..46567f26857bb 100644 --- a/clients/client-migrationhubstrategy/src/protocols/Aws_restJson1.ts +++ b/clients/client-migrationhubstrategy/src/protocols/Aws_restJson1.ts @@ -751,8 +751,7 @@ const deserializeAws_restJson1GetApplicationComponentDetailsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubstrategy#InternalServerException": @@ -765,10 +764,12 @@ const deserializeAws_restJson1GetApplicationComponentDetailsCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -804,8 +805,7 @@ const deserializeAws_restJson1GetApplicationComponentStrategiesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubstrategy#InternalServerException": @@ -818,10 +818,12 @@ const deserializeAws_restJson1GetApplicationComponentStrategiesCommandError = as throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -858,8 +860,7 @@ const deserializeAws_restJson1GetAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -875,10 +876,12 @@ const deserializeAws_restJson1GetAssessmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -951,8 +954,7 @@ const deserializeAws_restJson1GetImportFileTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -971,10 +973,12 @@ const deserializeAws_restJson1GetImportFileTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1021,8 +1025,7 @@ const deserializeAws_restJson1GetPortfolioPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1038,10 +1041,12 @@ const deserializeAws_restJson1GetPortfolioPreferencesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1074,8 +1079,7 @@ const deserializeAws_restJson1GetPortfolioSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1088,10 +1092,12 @@ const deserializeAws_restJson1GetPortfolioSummaryCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1131,8 +1137,7 @@ const deserializeAws_restJson1GetRecommendationReportDetailsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1151,10 +1156,12 @@ const deserializeAws_restJson1GetRecommendationReportDetailsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1198,8 +1205,7 @@ const deserializeAws_restJson1GetServerDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1218,10 +1224,12 @@ const deserializeAws_restJson1GetServerDetailsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1254,8 +1262,7 @@ const deserializeAws_restJson1GetServerStrategiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1274,10 +1281,12 @@ const deserializeAws_restJson1GetServerStrategiesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1317,8 +1326,7 @@ const deserializeAws_restJson1ListApplicationComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1334,10 +1342,12 @@ const deserializeAws_restJson1ListApplicationComponentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1374,8 +1384,7 @@ const deserializeAws_restJson1ListCollectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1391,10 +1400,12 @@ const deserializeAws_restJson1ListCollectorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1431,8 +1442,7 @@ const deserializeAws_restJson1ListImportFileTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1448,10 +1458,12 @@ const deserializeAws_restJson1ListImportFileTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1488,8 +1500,7 @@ const deserializeAws_restJson1ListServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1505,10 +1516,12 @@ const deserializeAws_restJson1ListServersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1537,8 +1550,7 @@ const deserializeAws_restJson1PutPortfolioPreferencesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1557,10 +1569,12 @@ const deserializeAws_restJson1PutPortfolioPreferencesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1593,8 +1607,7 @@ const deserializeAws_restJson1StartAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1610,10 +1623,12 @@ const deserializeAws_restJson1StartAssessmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1646,8 +1661,7 @@ const deserializeAws_restJson1StartImportFileTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1666,10 +1680,12 @@ const deserializeAws_restJson1StartImportFileTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1702,8 +1718,7 @@ const deserializeAws_restJson1StartRecommendationReportGenerationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1722,10 +1737,12 @@ const deserializeAws_restJson1StartRecommendationReportGenerationCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1754,8 +1771,7 @@ const deserializeAws_restJson1StopAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.migrationhubstrategy#AccessDeniedException": @@ -1771,10 +1787,12 @@ const deserializeAws_restJson1StopAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1803,8 +1821,7 @@ const deserializeAws_restJson1UpdateApplicationComponentConfigCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubstrategy#InternalServerException": @@ -1820,10 +1837,12 @@ const deserializeAws_restJson1UpdateApplicationComponentConfigCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1852,8 +1871,7 @@ const deserializeAws_restJson1UpdateServerConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.migrationhubstrategy#InternalServerException": @@ -1869,10 +1887,12 @@ const deserializeAws_restJson1UpdateServerConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3090,7 +3110,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3116,6 +3136,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mobile/src/protocols/Aws_restJson1.ts b/clients/client-mobile/src/protocols/Aws_restJson1.ts index 0a1e9dc434ab8..3f1e3bff645e9 100644 --- a/clients/client-mobile/src/protocols/Aws_restJson1.ts +++ b/clients/client-mobile/src/protocols/Aws_restJson1.ts @@ -315,8 +315,7 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -341,10 +340,12 @@ const deserializeAws_restJson1CreateProjectCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -381,8 +382,7 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.mobile#InternalFailureException": @@ -401,10 +401,12 @@ const deserializeAws_restJson1DeleteProjectCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -437,8 +439,7 @@ const deserializeAws_restJson1DescribeBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -460,10 +461,12 @@ const deserializeAws_restJson1DescribeBundleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -496,8 +499,7 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -519,10 +521,12 @@ const deserializeAws_restJson1DescribeProjectCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -555,8 +559,7 @@ const deserializeAws_restJson1ExportBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -578,10 +581,12 @@ const deserializeAws_restJson1ExportBundleCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -622,8 +627,7 @@ const deserializeAws_restJson1ExportProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -645,10 +649,12 @@ const deserializeAws_restJson1ExportProjectCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -685,8 +691,7 @@ const deserializeAws_restJson1ListBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -705,10 +710,12 @@ const deserializeAws_restJson1ListBundlesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -745,8 +752,7 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mobile#BadRequestException": @@ -765,10 +771,12 @@ const deserializeAws_restJson1ListProjectsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -801,8 +809,7 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountActionRequiredException": case "com.amazonaws.mobile#AccountActionRequiredException": @@ -830,10 +837,12 @@ const deserializeAws_restJson1UpdateProjectCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1129,7 +1138,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1155,6 +1164,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mq/src/protocols/Aws_restJson1.ts b/clients/client-mq/src/protocols/Aws_restJson1.ts index a7a6cd7576f36..f5d3e5bf8424a 100644 --- a/clients/client-mq/src/protocols/Aws_restJson1.ts +++ b/clients/client-mq/src/protocols/Aws_restJson1.ts @@ -896,8 +896,7 @@ const deserializeAws_restJson1CreateBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -916,10 +915,12 @@ const deserializeAws_restJson1CreateBrokerCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -972,8 +973,7 @@ const deserializeAws_restJson1CreateConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -989,10 +989,12 @@ const deserializeAws_restJson1CreateConfigurationCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1021,8 +1023,7 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1038,10 +1039,12 @@ const deserializeAws_restJson1CreateTagsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1070,8 +1073,7 @@ const deserializeAws_restJson1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1090,10 +1092,12 @@ const deserializeAws_restJson1CreateUserCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1126,8 +1130,7 @@ const deserializeAws_restJson1DeleteBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1143,10 +1146,12 @@ const deserializeAws_restJson1DeleteBrokerCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1175,8 +1180,7 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1192,10 +1196,12 @@ const deserializeAws_restJson1DeleteTagsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1224,8 +1230,7 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1241,10 +1246,12 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1395,8 +1402,7 @@ const deserializeAws_restJson1DescribeBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1412,10 +1418,12 @@ const deserializeAws_restJson1DescribeBrokerCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1456,8 +1464,7 @@ const deserializeAws_restJson1DescribeBrokerEngineTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1470,10 +1477,12 @@ const deserializeAws_restJson1DescribeBrokerEngineTypesCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1517,8 +1526,7 @@ const deserializeAws_restJson1DescribeBrokerInstanceOptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1531,10 +1539,12 @@ const deserializeAws_restJson1DescribeBrokerInstanceOptionsCommandError = async throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1613,7 @@ const deserializeAws_restJson1DescribeConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1620,10 +1629,12 @@ const deserializeAws_restJson1DescribeConfigurationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1668,8 +1679,7 @@ const deserializeAws_restJson1DescribeConfigurationRevisionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1685,10 +1695,12 @@ const deserializeAws_restJson1DescribeConfigurationRevisionCommandError = async throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1737,8 +1749,7 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1754,10 +1765,12 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1794,8 +1807,7 @@ const deserializeAws_restJson1ListBrokersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1808,10 +1820,12 @@ const deserializeAws_restJson1ListBrokersCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1856,8 +1870,7 @@ const deserializeAws_restJson1ListConfigurationRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1873,10 +1886,12 @@ const deserializeAws_restJson1ListConfigurationRevisionsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1917,8 +1932,7 @@ const deserializeAws_restJson1ListConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1931,10 +1945,12 @@ const deserializeAws_restJson1ListConfigurationsCommandError = async ( throw await deserializeAws_restJson1InternalServerErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1967,8 +1983,7 @@ const deserializeAws_restJson1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -1984,10 +1999,12 @@ const deserializeAws_restJson1ListTagsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2032,8 +2049,7 @@ const deserializeAws_restJson1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -2049,10 +2065,12 @@ const deserializeAws_restJson1ListUsersCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2081,8 +2099,7 @@ const deserializeAws_restJson1RebootBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -2098,10 +2115,12 @@ const deserializeAws_restJson1RebootBrokerCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2173,8 +2192,7 @@ const deserializeAws_restJson1UpdateBrokerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -2193,10 +2211,12 @@ const deserializeAws_restJson1UpdateBrokerCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2249,8 +2269,7 @@ const deserializeAws_restJson1UpdateConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -2269,10 +2288,12 @@ const deserializeAws_restJson1UpdateConfigurationCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2301,8 +2322,7 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.mq#BadRequestException": @@ -2321,10 +2341,12 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2997,7 +3019,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3023,6 +3045,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mturk/src/protocols/Aws_json1_1.ts b/clients/client-mturk/src/protocols/Aws_json1_1.ts index 09211f26d7796..2e2fac1b93386 100644 --- a/clients/client-mturk/src/protocols/Aws_json1_1.ts +++ b/clients/client-mturk/src/protocols/Aws_json1_1.ts @@ -757,8 +757,7 @@ const deserializeAws_json1_1AcceptQualificationRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -768,10 +767,12 @@ const deserializeAws_json1_1AcceptQualificationRequestCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -803,8 +804,7 @@ const deserializeAws_json1_1ApproveAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -814,10 +814,12 @@ const deserializeAws_json1_1ApproveAssignmentCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -849,8 +851,7 @@ const deserializeAws_json1_1AssociateQualificationWithWorkerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -860,10 +861,12 @@ const deserializeAws_json1_1AssociateQualificationWithWorkerCommandError = async throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -895,8 +898,7 @@ const deserializeAws_json1_1CreateAdditionalAssignmentsForHITCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -906,10 +908,12 @@ const deserializeAws_json1_1CreateAdditionalAssignmentsForHITCommandError = asyn throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -941,8 +945,7 @@ const deserializeAws_json1_1CreateHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -952,10 +955,12 @@ const deserializeAws_json1_1CreateHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -987,8 +992,7 @@ const deserializeAws_json1_1CreateHITTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -998,10 +1002,12 @@ const deserializeAws_json1_1CreateHITTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1033,8 +1039,7 @@ const deserializeAws_json1_1CreateHITWithHITTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1044,10 +1049,12 @@ const deserializeAws_json1_1CreateHITWithHITTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1079,8 +1086,7 @@ const deserializeAws_json1_1CreateQualificationTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1090,10 +1096,12 @@ const deserializeAws_json1_1CreateQualificationTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1125,8 +1133,7 @@ const deserializeAws_json1_1CreateWorkerBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1136,10 +1143,12 @@ const deserializeAws_json1_1CreateWorkerBlockCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1171,8 +1180,7 @@ const deserializeAws_json1_1DeleteHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1182,10 +1190,12 @@ const deserializeAws_json1_1DeleteHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1217,8 +1227,7 @@ const deserializeAws_json1_1DeleteQualificationTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1228,10 +1237,12 @@ const deserializeAws_json1_1DeleteQualificationTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1263,8 +1274,7 @@ const deserializeAws_json1_1DeleteWorkerBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1274,10 +1284,12 @@ const deserializeAws_json1_1DeleteWorkerBlockCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1309,8 +1321,7 @@ const deserializeAws_json1_1DisassociateQualificationFromWorkerCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1320,10 +1331,12 @@ const deserializeAws_json1_1DisassociateQualificationFromWorkerCommandError = as throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1355,8 +1368,7 @@ const deserializeAws_json1_1GetAccountBalanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1366,10 +1378,12 @@ const deserializeAws_json1_1GetAccountBalanceCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1401,8 +1415,7 @@ const deserializeAws_json1_1GetAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1412,10 +1425,12 @@ const deserializeAws_json1_1GetAssignmentCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1447,8 +1462,7 @@ const deserializeAws_json1_1GetFileUploadURLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1458,10 +1472,12 @@ const deserializeAws_json1_1GetFileUploadURLCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1493,8 +1509,7 @@ const deserializeAws_json1_1GetHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1504,10 +1519,12 @@ const deserializeAws_json1_1GetHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1539,8 +1556,7 @@ const deserializeAws_json1_1GetQualificationScoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1550,10 +1566,12 @@ const deserializeAws_json1_1GetQualificationScoreCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1585,8 +1603,7 @@ const deserializeAws_json1_1GetQualificationTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1596,10 +1613,12 @@ const deserializeAws_json1_1GetQualificationTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1650,7 @@ const deserializeAws_json1_1ListAssignmentsForHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1642,10 +1660,12 @@ const deserializeAws_json1_1ListAssignmentsForHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,8 +1697,7 @@ const deserializeAws_json1_1ListBonusPaymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1688,10 +1707,12 @@ const deserializeAws_json1_1ListBonusPaymentsCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1744,7 @@ const deserializeAws_json1_1ListHITsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1734,10 +1754,12 @@ const deserializeAws_json1_1ListHITsCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1769,8 +1791,7 @@ const deserializeAws_json1_1ListHITsForQualificationTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1780,10 +1801,12 @@ const deserializeAws_json1_1ListHITsForQualificationTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1815,8 +1838,7 @@ const deserializeAws_json1_1ListQualificationRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1826,10 +1848,12 @@ const deserializeAws_json1_1ListQualificationRequestsCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1861,8 +1885,7 @@ const deserializeAws_json1_1ListQualificationTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1872,10 +1895,12 @@ const deserializeAws_json1_1ListQualificationTypesCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1907,8 +1932,7 @@ const deserializeAws_json1_1ListReviewableHITsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1918,10 +1942,12 @@ const deserializeAws_json1_1ListReviewableHITsCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,8 +1979,7 @@ const deserializeAws_json1_1ListReviewPolicyResultsForHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -1964,10 +1989,12 @@ const deserializeAws_json1_1ListReviewPolicyResultsForHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1999,8 +2026,7 @@ const deserializeAws_json1_1ListWorkerBlocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2010,10 +2036,12 @@ const deserializeAws_json1_1ListWorkerBlocksCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2073,7 @@ const deserializeAws_json1_1ListWorkersWithQualificationTypeCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2056,10 +2083,12 @@ const deserializeAws_json1_1ListWorkersWithQualificationTypeCommandError = async throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2091,8 +2120,7 @@ const deserializeAws_json1_1NotifyWorkersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2102,10 +2130,12 @@ const deserializeAws_json1_1NotifyWorkersCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2137,8 +2167,7 @@ const deserializeAws_json1_1RejectAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2148,10 +2177,12 @@ const deserializeAws_json1_1RejectAssignmentCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2183,8 +2214,7 @@ const deserializeAws_json1_1RejectQualificationRequestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2194,10 +2224,12 @@ const deserializeAws_json1_1RejectQualificationRequestCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2229,8 +2261,7 @@ const deserializeAws_json1_1SendBonusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2240,10 +2271,12 @@ const deserializeAws_json1_1SendBonusCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2275,8 +2308,7 @@ const deserializeAws_json1_1SendTestEventNotificationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2286,10 +2318,12 @@ const deserializeAws_json1_1SendTestEventNotificationCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2321,8 +2355,7 @@ const deserializeAws_json1_1UpdateExpirationForHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2332,10 +2365,12 @@ const deserializeAws_json1_1UpdateExpirationForHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2367,8 +2402,7 @@ const deserializeAws_json1_1UpdateHITReviewStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2378,10 +2412,12 @@ const deserializeAws_json1_1UpdateHITReviewStatusCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2413,8 +2449,7 @@ const deserializeAws_json1_1UpdateHITTypeOfHITCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2424,10 +2459,12 @@ const deserializeAws_json1_1UpdateHITTypeOfHITCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2459,8 +2496,7 @@ const deserializeAws_json1_1UpdateNotificationSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2470,10 +2506,12 @@ const deserializeAws_json1_1UpdateNotificationSettingsCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2505,8 +2543,7 @@ const deserializeAws_json1_1UpdateQualificationTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "RequestError": case "com.amazonaws.mturk#RequestError": @@ -2516,10 +2553,12 @@ const deserializeAws_json1_1UpdateQualificationTypeCommandError = async ( throw await deserializeAws_json1_1ServiceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4161,7 +4200,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4187,6 +4226,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-mwaa/src/protocols/Aws_restJson1.ts b/clients/client-mwaa/src/protocols/Aws_restJson1.ts index a7c1f71c83b83..e1b6bd6877982 100644 --- a/clients/client-mwaa/src/protocols/Aws_restJson1.ts +++ b/clients/client-mwaa/src/protocols/Aws_restJson1.ts @@ -580,18 +580,19 @@ const deserializeAws_restJson1CreateCliTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.mwaa#ResourceNotFoundException": throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -624,8 +625,7 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -635,10 +635,12 @@ const deserializeAws_restJson1CreateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -675,8 +677,7 @@ const deserializeAws_restJson1CreateWebLoginTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.mwaa#AccessDeniedException": @@ -692,10 +693,12 @@ const deserializeAws_restJson1CreateWebLoginTokenCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -724,8 +727,7 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -738,10 +740,12 @@ const deserializeAws_restJson1DeleteEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -774,8 +778,7 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -788,10 +791,12 @@ const deserializeAws_restJson1GetEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -828,8 +833,7 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -839,10 +843,12 @@ const deserializeAws_restJson1ListEnvironmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -875,8 +881,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -889,10 +894,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -921,8 +928,7 @@ const deserializeAws_restJson1PublishMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -932,10 +938,12 @@ const deserializeAws_restJson1PublishMetricsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -964,8 +972,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -978,10 +985,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1010,8 +1019,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -1024,10 +1032,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1060,8 +1070,7 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.mwaa#InternalServerException": @@ -1074,10 +1083,12 @@ const deserializeAws_restJson1UpdateEnvironmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1531,7 +1542,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1557,6 +1568,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-neptune/src/protocols/Aws_query.ts b/clients/client-neptune/src/protocols/Aws_query.ts index d78b7d2d57dd1..52802af6231ad 100644 --- a/clients/client-neptune/src/protocols/Aws_query.ts +++ b/clients/client-neptune/src/protocols/Aws_query.ts @@ -1626,8 +1626,7 @@ const deserializeAws_queryAddRoleToDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -1643,10 +1642,12 @@ const deserializeAws_queryAddRoleToDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1681,8 +1682,7 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.neptune#SourceNotFoundFault": @@ -1692,10 +1692,12 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1724,8 +1726,7 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -1738,10 +1739,12 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1773,18 +1776,19 @@ const deserializeAws_queryApplyPendingMaintenanceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.neptune#ResourceNotFoundFault": throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1816,8 +1820,7 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.neptune#DBParameterGroupAlreadyExistsFault": @@ -1830,10 +1833,12 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1865,8 +1870,7 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterSnapshotAlreadyExistsFault": @@ -1888,10 +1892,12 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1923,8 +1929,7 @@ const deserializeAws_queryCopyDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.neptune#DBParameterGroupAlreadyExistsFault": @@ -1937,10 +1942,12 @@ const deserializeAws_queryCopyDBParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1972,8 +1979,7 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterAlreadyExistsFault": @@ -2028,10 +2034,12 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2063,8 +2071,7 @@ const deserializeAws_queryCreateDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterEndpointAlreadyExistsFault": @@ -2086,10 +2093,12 @@ const deserializeAws_queryCreateDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2121,8 +2130,7 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.neptune#DBParameterGroupAlreadyExistsFault": @@ -2132,10 +2140,12 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2167,8 +2177,7 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -2187,10 +2196,12 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2222,8 +2233,7 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.neptune#AuthorizationNotFoundFault": @@ -2281,10 +2291,12 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2316,8 +2328,7 @@ const deserializeAws_queryCreateDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.neptune#DBParameterGroupAlreadyExistsFault": @@ -2327,10 +2338,12 @@ const deserializeAws_queryCreateDBParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2362,8 +2375,7 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupAlreadyExistsFault": case "com.amazonaws.neptune#DBSubnetGroupAlreadyExistsFault": @@ -2382,10 +2394,12 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidSubnetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2417,8 +2431,7 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.neptune#EventSubscriptionQuotaExceededFault": @@ -2443,10 +2456,12 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionCategoryNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2478,8 +2493,7 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -2495,10 +2509,12 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2530,8 +2546,7 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -2550,10 +2565,12 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2585,8 +2602,7 @@ const deserializeAws_queryDeleteDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointNotFoundFault": case "com.amazonaws.neptune#DBClusterEndpointNotFoundFault": @@ -2599,10 +2615,12 @@ const deserializeAws_queryDeleteDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2631,8 +2649,7 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -2642,10 +2659,12 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2677,8 +2696,7 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.neptune#DBClusterSnapshotNotFoundFault": @@ -2688,10 +2706,12 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidDBClusterSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2723,8 +2743,7 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.neptune#DBInstanceNotFoundFault": @@ -2743,10 +2762,12 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2775,8 +2796,7 @@ const deserializeAws_queryDeleteDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -2786,10 +2806,12 @@ const deserializeAws_queryDeleteDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2818,8 +2840,7 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.neptune#DBSubnetGroupNotFoundFault": @@ -2832,10 +2853,12 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidDBSubnetStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2867,8 +2890,7 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEventSubscriptionStateFault": case "com.amazonaws.neptune#InvalidEventSubscriptionStateFault": @@ -2878,10 +2900,12 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2913,8 +2937,7 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.neptune#GlobalClusterNotFoundFault": @@ -2924,10 +2947,12 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2959,18 +2984,19 @@ const deserializeAws_queryDescribeDBClusterEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3002,18 +3028,19 @@ const deserializeAws_queryDescribeDBClusterParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3045,18 +3072,19 @@ const deserializeAws_queryDescribeDBClusterParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3088,18 +3116,19 @@ const deserializeAws_queryDescribeDBClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3134,18 +3163,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotAttributesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.neptune#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3177,18 +3207,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.neptune#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3220,15 +3251,16 @@ const deserializeAws_queryDescribeDBEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3260,18 +3292,19 @@ const deserializeAws_queryDescribeDBInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.neptune#DBInstanceNotFoundFault": throw await deserializeAws_queryDBInstanceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3303,18 +3336,19 @@ const deserializeAws_queryDescribeDBParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3346,18 +3380,19 @@ const deserializeAws_queryDescribeDBParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3389,18 +3424,19 @@ const deserializeAws_queryDescribeDBSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.neptune#DBSubnetGroupNotFoundFault": throw await deserializeAws_queryDBSubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3435,15 +3471,16 @@ const deserializeAws_queryDescribeEngineDefaultClusterParametersCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3478,15 +3515,16 @@ const deserializeAws_queryDescribeEngineDefaultParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3518,15 +3556,16 @@ const deserializeAws_queryDescribeEventCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3558,15 +3597,16 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3598,18 +3638,19 @@ const deserializeAws_queryDescribeEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SubscriptionNotFoundFault": case "com.amazonaws.neptune#SubscriptionNotFoundFault": throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3641,18 +3682,19 @@ const deserializeAws_queryDescribeGlobalClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.neptune#GlobalClusterNotFoundFault": throw await deserializeAws_queryGlobalClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3687,15 +3729,16 @@ const deserializeAws_queryDescribeOrderableDBInstanceOptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3730,18 +3773,19 @@ const deserializeAws_queryDescribePendingMaintenanceActionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.neptune#ResourceNotFoundFault": throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3776,8 +3820,7 @@ const deserializeAws_queryDescribeValidDBInstanceModificationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.neptune#DBInstanceNotFoundFault": @@ -3787,10 +3830,12 @@ const deserializeAws_queryDescribeValidDBInstanceModificationsCommandError = asy throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3822,8 +3867,7 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -3836,10 +3880,12 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3871,8 +3917,7 @@ const deserializeAws_queryFailoverGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -3888,10 +3933,12 @@ const deserializeAws_queryFailoverGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3923,8 +3970,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -3937,10 +3983,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3972,8 +4020,7 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterAlreadyExistsFault": @@ -4010,10 +4057,12 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4045,8 +4094,7 @@ const deserializeAws_queryModifyDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointNotFoundFault": case "com.amazonaws.neptune#DBClusterEndpointNotFoundFault": @@ -4065,10 +4113,12 @@ const deserializeAws_queryModifyDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4100,8 +4150,7 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -4111,10 +4160,12 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4149,8 +4200,7 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.neptune#DBClusterSnapshotNotFoundFault": @@ -4163,10 +4213,12 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( throw await deserializeAws_querySharedSnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4198,8 +4250,7 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.neptune#AuthorizationNotFoundFault": @@ -4251,10 +4302,12 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4286,8 +4339,7 @@ const deserializeAws_queryModifyDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -4297,10 +4349,12 @@ const deserializeAws_queryModifyDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4332,8 +4386,7 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupDoesNotCoverEnoughAZs": case "com.amazonaws.neptune#DBSubnetGroupDoesNotCoverEnoughAZs": @@ -4352,10 +4405,12 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( throw await deserializeAws_querySubnetAlreadyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4387,8 +4442,7 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.neptune#EventSubscriptionQuotaExceededFault": @@ -4410,10 +4464,12 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4445,8 +4501,7 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.neptune#GlobalClusterNotFoundFault": @@ -4456,10 +4511,12 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4491,8 +4548,7 @@ const deserializeAws_queryPromoteReadReplicaDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -4502,10 +4558,12 @@ const deserializeAws_queryPromoteReadReplicaDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4537,8 +4595,7 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.neptune#DBInstanceNotFoundFault": @@ -4548,10 +4605,12 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4583,8 +4642,7 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -4597,10 +4655,12 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4629,8 +4689,7 @@ const deserializeAws_queryRemoveRoleFromDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -4643,10 +4702,12 @@ const deserializeAws_queryRemoveRoleFromDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4681,8 +4742,7 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.neptune#SourceNotFoundFault": @@ -4692,10 +4752,12 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4724,8 +4786,7 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -4738,10 +4799,12 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4773,8 +4836,7 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -4784,10 +4846,12 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4819,8 +4883,7 @@ const deserializeAws_queryResetDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.neptune#DBParameterGroupNotFoundFault": @@ -4830,10 +4893,12 @@ const deserializeAws_queryResetDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4865,8 +4930,7 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterAlreadyExistsFault": @@ -4918,10 +4982,12 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4953,8 +5019,7 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.neptune#DBClusterAlreadyExistsFault": @@ -5009,10 +5074,12 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5044,8 +5111,7 @@ const deserializeAws_queryStartDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -5058,10 +5124,12 @@ const deserializeAws_queryStartDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5093,8 +5161,7 @@ const deserializeAws_queryStopDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.neptune#DBClusterNotFoundFault": @@ -5107,10 +5174,12 @@ const deserializeAws_queryStopDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -12376,12 +12445,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-network-firewall/src/protocols/Aws_json1_0.ts b/clients/client-network-firewall/src/protocols/Aws_json1_0.ts index 6421cdd2c1cb0..e5db768c0f7e9 100644 --- a/clients/client-network-firewall/src/protocols/Aws_json1_0.ts +++ b/clients/client-network-firewall/src/protocols/Aws_json1_0.ts @@ -652,8 +652,7 @@ const deserializeAws_json1_0AssociateFirewallPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -675,10 +674,12 @@ const deserializeAws_json1_0AssociateFirewallPolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -710,8 +711,7 @@ const deserializeAws_json1_0AssociateSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapacityException": case "com.amazonaws.networkfirewall#InsufficientCapacityException": @@ -736,10 +736,12 @@ const deserializeAws_json1_0AssociateSubnetsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -771,8 +773,7 @@ const deserializeAws_json1_0CreateFirewallCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapacityException": case "com.amazonaws.networkfirewall#InsufficientCapacityException": @@ -794,10 +795,12 @@ const deserializeAws_json1_0CreateFirewallCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -829,8 +832,7 @@ const deserializeAws_json1_0CreateFirewallPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapacityException": case "com.amazonaws.networkfirewall#InsufficientCapacityException": @@ -849,10 +851,12 @@ const deserializeAws_json1_0CreateFirewallPolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -884,8 +888,7 @@ const deserializeAws_json1_0CreateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InsufficientCapacityException": case "com.amazonaws.networkfirewall#InsufficientCapacityException": @@ -904,10 +907,12 @@ const deserializeAws_json1_0CreateRuleGroupCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -939,8 +944,7 @@ const deserializeAws_json1_0DeleteFirewallCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -962,10 +966,12 @@ const deserializeAws_json1_0DeleteFirewallCommandError = async ( throw await deserializeAws_json1_0UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -997,8 +1003,7 @@ const deserializeAws_json1_0DeleteFirewallPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1020,10 +1025,12 @@ const deserializeAws_json1_0DeleteFirewallPolicyCommandError = async ( throw await deserializeAws_json1_0UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1055,8 +1062,7 @@ const deserializeAws_json1_0DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1075,10 +1081,12 @@ const deserializeAws_json1_0DeleteResourcePolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1110,8 +1118,7 @@ const deserializeAws_json1_0DeleteRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1133,10 +1140,12 @@ const deserializeAws_json1_0DeleteRuleGroupCommandError = async ( throw await deserializeAws_json1_0UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1168,8 +1177,7 @@ const deserializeAws_json1_0DescribeFirewallCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1185,10 +1193,12 @@ const deserializeAws_json1_0DescribeFirewallCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1220,8 +1230,7 @@ const deserializeAws_json1_0DescribeFirewallPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1237,10 +1246,12 @@ const deserializeAws_json1_0DescribeFirewallPolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1272,8 +1283,7 @@ const deserializeAws_json1_0DescribeLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1289,10 +1299,12 @@ const deserializeAws_json1_0DescribeLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1324,8 +1336,7 @@ const deserializeAws_json1_0DescribeResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1341,10 +1352,12 @@ const deserializeAws_json1_0DescribeResourcePolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1376,8 +1389,7 @@ const deserializeAws_json1_0DescribeRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1393,10 +1405,12 @@ const deserializeAws_json1_0DescribeRuleGroupCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1428,8 +1442,7 @@ const deserializeAws_json1_0DescribeRuleGroupMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1445,10 +1458,12 @@ const deserializeAws_json1_0DescribeRuleGroupMetadataCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1480,8 +1495,7 @@ const deserializeAws_json1_0DisassociateSubnetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1503,10 +1517,12 @@ const deserializeAws_json1_0DisassociateSubnetsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1538,8 +1554,7 @@ const deserializeAws_json1_0ListFirewallPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1552,10 +1567,12 @@ const deserializeAws_json1_0ListFirewallPoliciesCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1587,8 +1604,7 @@ const deserializeAws_json1_0ListFirewallsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1601,10 +1617,12 @@ const deserializeAws_json1_0ListFirewallsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1636,8 +1654,7 @@ const deserializeAws_json1_0ListRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1650,10 +1667,12 @@ const deserializeAws_json1_0ListRuleGroupsCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1685,8 +1704,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1702,10 +1720,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1737,8 +1757,7 @@ const deserializeAws_json1_0PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1757,10 +1776,12 @@ const deserializeAws_json1_0PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1792,8 +1813,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1809,10 +1829,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1844,8 +1866,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1861,10 +1882,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1896,8 +1919,7 @@ const deserializeAws_json1_0UpdateFirewallDeleteProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1919,10 +1941,12 @@ const deserializeAws_json1_0UpdateFirewallDeleteProtectionCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1954,8 +1978,7 @@ const deserializeAws_json1_0UpdateFirewallDescriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -1974,10 +1997,12 @@ const deserializeAws_json1_0UpdateFirewallDescriptionCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2009,8 +2034,7 @@ const deserializeAws_json1_0UpdateFirewallEncryptionConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2032,10 +2056,12 @@ const deserializeAws_json1_0UpdateFirewallEncryptionConfigurationCommandError = throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2067,8 +2093,7 @@ const deserializeAws_json1_0UpdateFirewallPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2087,10 +2112,12 @@ const deserializeAws_json1_0UpdateFirewallPolicyCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2122,8 +2149,7 @@ const deserializeAws_json1_0UpdateFirewallPolicyChangeProtectionCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2145,10 +2171,12 @@ const deserializeAws_json1_0UpdateFirewallPolicyChangeProtectionCommandError = a throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2180,8 +2208,7 @@ const deserializeAws_json1_0UpdateLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2203,10 +2230,12 @@ const deserializeAws_json1_0UpdateLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2238,8 +2267,7 @@ const deserializeAws_json1_0UpdateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2258,10 +2286,12 @@ const deserializeAws_json1_0UpdateRuleGroupCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2293,8 +2323,7 @@ const deserializeAws_json1_0UpdateSubnetChangeProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.networkfirewall#InternalServerError": @@ -2316,10 +2345,12 @@ const deserializeAws_json1_0UpdateSubnetChangeProtectionCommandError = async ( throw await deserializeAws_json1_0ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4936,7 +4967,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4962,6 +4993,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-networkmanager/src/protocols/Aws_restJson1.ts b/clients/client-networkmanager/src/protocols/Aws_restJson1.ts index 64c541e2f26a5..2e2c7d48a66f0 100644 --- a/clients/client-networkmanager/src/protocols/Aws_restJson1.ts +++ b/clients/client-networkmanager/src/protocols/Aws_restJson1.ts @@ -3135,8 +3135,7 @@ const deserializeAws_restJson1AcceptAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3158,10 +3157,12 @@ const deserializeAws_restJson1AcceptAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3197,8 +3198,7 @@ const deserializeAws_restJson1AssociateConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3223,10 +3223,12 @@ const deserializeAws_restJson1AssociateConnectPeerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3262,8 +3264,7 @@ const deserializeAws_restJson1AssociateCustomerGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3288,10 +3289,12 @@ const deserializeAws_restJson1AssociateCustomerGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3324,8 +3327,7 @@ const deserializeAws_restJson1AssociateLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3350,10 +3352,12 @@ const deserializeAws_restJson1AssociateLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3389,8 +3393,7 @@ const deserializeAws_restJson1AssociateTransitGatewayConnectPeerCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3415,10 +3418,12 @@ const deserializeAws_restJson1AssociateTransitGatewayConnectPeerCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3451,8 +3456,7 @@ const deserializeAws_restJson1CreateConnectAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3474,10 +3478,12 @@ const deserializeAws_restJson1CreateConnectAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3510,8 +3516,7 @@ const deserializeAws_restJson1CreateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3533,10 +3538,12 @@ const deserializeAws_restJson1CreateConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3569,8 +3576,7 @@ const deserializeAws_restJson1CreateConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3592,10 +3598,12 @@ const deserializeAws_restJson1CreateConnectPeerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3628,8 +3636,7 @@ const deserializeAws_restJson1CreateCoreNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3654,10 +3661,12 @@ const deserializeAws_restJson1CreateCoreNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3690,8 +3699,7 @@ const deserializeAws_restJson1CreateDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3716,10 +3724,12 @@ const deserializeAws_restJson1CreateDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3752,8 +3762,7 @@ const deserializeAws_restJson1CreateGlobalNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3775,10 +3784,12 @@ const deserializeAws_restJson1CreateGlobalNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3811,8 +3822,7 @@ const deserializeAws_restJson1CreateLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3837,10 +3847,12 @@ const deserializeAws_restJson1CreateLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3873,8 +3885,7 @@ const deserializeAws_restJson1CreateSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3899,10 +3910,12 @@ const deserializeAws_restJson1CreateSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3938,8 +3951,7 @@ const deserializeAws_restJson1CreateSiteToSiteVpnAttachmentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -3961,10 +3973,12 @@ const deserializeAws_restJson1CreateSiteToSiteVpnAttachmentCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3997,8 +4011,7 @@ const deserializeAws_restJson1CreateVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4020,10 +4033,12 @@ const deserializeAws_restJson1CreateVpcAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4056,8 +4071,7 @@ const deserializeAws_restJson1DeleteAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4079,10 +4093,12 @@ const deserializeAws_restJson1DeleteAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4115,8 +4131,7 @@ const deserializeAws_restJson1DeleteConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4138,10 +4153,12 @@ const deserializeAws_restJson1DeleteConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4174,8 +4191,7 @@ const deserializeAws_restJson1DeleteConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4197,10 +4213,12 @@ const deserializeAws_restJson1DeleteConnectPeerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4233,8 +4251,7 @@ const deserializeAws_restJson1DeleteCoreNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4256,10 +4273,12 @@ const deserializeAws_restJson1DeleteCoreNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4292,8 +4311,7 @@ const deserializeAws_restJson1DeleteCoreNetworkPolicyVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4315,10 +4333,12 @@ const deserializeAws_restJson1DeleteCoreNetworkPolicyVersionCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4351,8 +4371,7 @@ const deserializeAws_restJson1DeleteDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4374,10 +4393,12 @@ const deserializeAws_restJson1DeleteDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4410,8 +4431,7 @@ const deserializeAws_restJson1DeleteGlobalNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4433,10 +4453,12 @@ const deserializeAws_restJson1DeleteGlobalNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4469,8 +4491,7 @@ const deserializeAws_restJson1DeleteLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4492,10 +4513,12 @@ const deserializeAws_restJson1DeleteLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4524,8 +4547,7 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4544,10 +4566,12 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4580,8 +4604,7 @@ const deserializeAws_restJson1DeleteSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4603,10 +4626,12 @@ const deserializeAws_restJson1DeleteSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4642,8 +4667,7 @@ const deserializeAws_restJson1DeregisterTransitGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4665,10 +4689,12 @@ const deserializeAws_restJson1DeregisterTransitGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4705,8 +4731,7 @@ const deserializeAws_restJson1DescribeGlobalNetworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4725,10 +4750,12 @@ const deserializeAws_restJson1DescribeGlobalNetworksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4764,8 +4791,7 @@ const deserializeAws_restJson1DisassociateConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4787,10 +4813,12 @@ const deserializeAws_restJson1DisassociateConnectPeerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4826,8 +4854,7 @@ const deserializeAws_restJson1DisassociateCustomerGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4849,10 +4876,12 @@ const deserializeAws_restJson1DisassociateCustomerGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4885,8 +4914,7 @@ const deserializeAws_restJson1DisassociateLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4908,10 +4936,12 @@ const deserializeAws_restJson1DisassociateLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4947,8 +4977,7 @@ const deserializeAws_restJson1DisassociateTransitGatewayConnectPeerCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -4970,10 +4999,12 @@ const deserializeAws_restJson1DisassociateTransitGatewayConnectPeerCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5002,8 +5033,7 @@ const deserializeAws_restJson1ExecuteCoreNetworkChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5025,10 +5055,12 @@ const deserializeAws_restJson1ExecuteCoreNetworkChangeSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5061,8 +5093,7 @@ const deserializeAws_restJson1GetConnectAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5081,10 +5112,12 @@ const deserializeAws_restJson1GetConnectAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5121,8 +5154,7 @@ const deserializeAws_restJson1GetConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5141,10 +5173,12 @@ const deserializeAws_restJson1GetConnectionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5177,8 +5211,7 @@ const deserializeAws_restJson1GetConnectPeerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5197,10 +5230,12 @@ const deserializeAws_restJson1GetConnectPeerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5240,8 +5275,7 @@ const deserializeAws_restJson1GetConnectPeerAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5263,10 +5297,12 @@ const deserializeAws_restJson1GetConnectPeerAssociationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5299,8 +5335,7 @@ const deserializeAws_restJson1GetCoreNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5319,10 +5354,12 @@ const deserializeAws_restJson1GetCoreNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5359,8 +5396,7 @@ const deserializeAws_restJson1GetCoreNetworkChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5379,10 +5415,12 @@ const deserializeAws_restJson1GetCoreNetworkChangeSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5415,8 +5453,7 @@ const deserializeAws_restJson1GetCoreNetworkPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5435,10 +5472,12 @@ const deserializeAws_restJson1GetCoreNetworkPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5478,8 +5517,7 @@ const deserializeAws_restJson1GetCustomerGatewayAssociationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5501,10 +5539,12 @@ const deserializeAws_restJson1GetCustomerGatewayAssociationsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5541,8 +5581,7 @@ const deserializeAws_restJson1GetDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5561,10 +5600,12 @@ const deserializeAws_restJson1GetDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5601,8 +5642,7 @@ const deserializeAws_restJson1GetLinkAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5621,10 +5661,12 @@ const deserializeAws_restJson1GetLinkAssociationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5661,8 +5703,7 @@ const deserializeAws_restJson1GetLinksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5681,10 +5722,12 @@ const deserializeAws_restJson1GetLinksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5724,8 +5767,7 @@ const deserializeAws_restJson1GetNetworkResourceCountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5741,10 +5783,12 @@ const deserializeAws_restJson1GetNetworkResourceCountsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5781,8 +5825,7 @@ const deserializeAws_restJson1GetNetworkResourceRelationshipsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5801,10 +5844,12 @@ const deserializeAws_restJson1GetNetworkResourceRelationshipsCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5841,8 +5886,7 @@ const deserializeAws_restJson1GetNetworkResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5861,10 +5905,12 @@ const deserializeAws_restJson1GetNetworkResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5916,8 +5962,7 @@ const deserializeAws_restJson1GetNetworkRoutesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5936,10 +5981,12 @@ const deserializeAws_restJson1GetNetworkRoutesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5976,8 +6023,7 @@ const deserializeAws_restJson1GetNetworkTelemetryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -5996,10 +6042,12 @@ const deserializeAws_restJson1GetNetworkTelemetryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6032,8 +6080,7 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6049,10 +6096,12 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6085,8 +6134,7 @@ const deserializeAws_restJson1GetRouteAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6105,10 +6153,12 @@ const deserializeAws_restJson1GetRouteAnalysisCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6145,8 +6195,7 @@ const deserializeAws_restJson1GetSitesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6165,10 +6214,12 @@ const deserializeAws_restJson1GetSitesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6204,8 +6255,7 @@ const deserializeAws_restJson1GetSiteToSiteVpnAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6224,10 +6274,12 @@ const deserializeAws_restJson1GetSiteToSiteVpnAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6267,8 +6319,7 @@ const deserializeAws_restJson1GetTransitGatewayConnectPeerAssociationsCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6290,10 +6341,12 @@ const deserializeAws_restJson1GetTransitGatewayConnectPeerAssociationsCommandErr throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6333,8 +6386,7 @@ const deserializeAws_restJson1GetTransitGatewayRegistrationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6353,10 +6405,12 @@ const deserializeAws_restJson1GetTransitGatewayRegistrationsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6389,8 +6443,7 @@ const deserializeAws_restJson1GetVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6409,10 +6462,12 @@ const deserializeAws_restJson1GetVpcAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6449,8 +6504,7 @@ const deserializeAws_restJson1ListAttachmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6466,10 +6520,12 @@ const deserializeAws_restJson1ListAttachmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6506,8 +6562,7 @@ const deserializeAws_restJson1ListConnectPeersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6523,10 +6578,12 @@ const deserializeAws_restJson1ListConnectPeersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6566,8 +6623,7 @@ const deserializeAws_restJson1ListCoreNetworkPolicyVersionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6586,10 +6642,12 @@ const deserializeAws_restJson1ListCoreNetworkPolicyVersionsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6626,8 +6684,7 @@ const deserializeAws_restJson1ListCoreNetworksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6643,10 +6700,12 @@ const deserializeAws_restJson1ListCoreNetworksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6683,15 +6742,16 @@ const deserializeAws_restJson1ListOrganizationServiceAccessStatusCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6724,8 +6784,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6744,10 +6803,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6780,8 +6841,7 @@ const deserializeAws_restJson1PutCoreNetworkPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6806,10 +6866,12 @@ const deserializeAws_restJson1PutCoreNetworkPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6838,8 +6900,7 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6861,10 +6922,12 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6900,8 +6963,7 @@ const deserializeAws_restJson1RegisterTransitGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6923,10 +6985,12 @@ const deserializeAws_restJson1RegisterTransitGatewayCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6959,8 +7023,7 @@ const deserializeAws_restJson1RejectAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -6982,10 +7045,12 @@ const deserializeAws_restJson1RejectAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7018,8 +7083,7 @@ const deserializeAws_restJson1RestoreCoreNetworkPolicyVersionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7041,10 +7105,12 @@ const deserializeAws_restJson1RestoreCoreNetworkPolicyVersionCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7077,8 +7143,7 @@ const deserializeAws_restJson1StartOrganizationServiceAccessUpdateCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7100,10 +7165,12 @@ const deserializeAws_restJson1StartOrganizationServiceAccessUpdateCommandError = throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7136,8 +7203,7 @@ const deserializeAws_restJson1StartRouteAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7159,10 +7225,12 @@ const deserializeAws_restJson1StartRouteAnalysisCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7191,8 +7259,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7217,10 +7284,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7249,8 +7318,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7272,10 +7340,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7308,8 +7378,7 @@ const deserializeAws_restJson1UpdateConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7331,10 +7400,12 @@ const deserializeAws_restJson1UpdateConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7367,8 +7438,7 @@ const deserializeAws_restJson1UpdateCoreNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7390,10 +7460,12 @@ const deserializeAws_restJson1UpdateCoreNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7426,8 +7498,7 @@ const deserializeAws_restJson1UpdateDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7449,10 +7520,12 @@ const deserializeAws_restJson1UpdateDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7485,8 +7558,7 @@ const deserializeAws_restJson1UpdateGlobalNetworkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7508,10 +7580,12 @@ const deserializeAws_restJson1UpdateGlobalNetworkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7544,8 +7618,7 @@ const deserializeAws_restJson1UpdateLinkCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7570,10 +7643,12 @@ const deserializeAws_restJson1UpdateLinkCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7610,8 +7685,7 @@ const deserializeAws_restJson1UpdateNetworkResourceMetadataCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7633,10 +7707,12 @@ const deserializeAws_restJson1UpdateNetworkResourceMetadataCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7669,8 +7745,7 @@ const deserializeAws_restJson1UpdateSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7692,10 +7767,12 @@ const deserializeAws_restJson1UpdateSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7728,8 +7805,7 @@ const deserializeAws_restJson1UpdateVpcAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.networkmanager#AccessDeniedException": @@ -7751,10 +7827,12 @@ const deserializeAws_restJson1UpdateVpcAttachmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9373,7 +9451,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9399,6 +9477,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-nimble/src/protocols/Aws_restJson1.ts b/clients/client-nimble/src/protocols/Aws_restJson1.ts index 96afc47a9820a..a734b5c711fd0 100644 --- a/clients/client-nimble/src/protocols/Aws_restJson1.ts +++ b/clients/client-nimble/src/protocols/Aws_restJson1.ts @@ -2138,8 +2138,7 @@ const deserializeAws_restJson1AcceptEulasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2164,10 +2163,12 @@ const deserializeAws_restJson1AcceptEulasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2200,8 +2201,7 @@ const deserializeAws_restJson1CreateLaunchProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2226,10 +2226,12 @@ const deserializeAws_restJson1CreateLaunchProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2262,8 +2264,7 @@ const deserializeAws_restJson1CreateStreamingImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2288,10 +2289,12 @@ const deserializeAws_restJson1CreateStreamingImageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2324,8 +2327,7 @@ const deserializeAws_restJson1CreateStreamingSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2350,10 +2352,12 @@ const deserializeAws_restJson1CreateStreamingSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2390,7 @@ const deserializeAws_restJson1CreateStreamingSessionStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2412,10 +2415,12 @@ const deserializeAws_restJson1CreateStreamingSessionStreamCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2448,8 +2453,7 @@ const deserializeAws_restJson1CreateStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2474,10 +2478,12 @@ const deserializeAws_restJson1CreateStudioCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2510,8 +2516,7 @@ const deserializeAws_restJson1CreateStudioComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2536,10 +2541,12 @@ const deserializeAws_restJson1CreateStudioComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2572,8 +2579,7 @@ const deserializeAws_restJson1DeleteLaunchProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2598,10 +2604,12 @@ const deserializeAws_restJson1DeleteLaunchProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2630,8 +2638,7 @@ const deserializeAws_restJson1DeleteLaunchProfileMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2656,10 +2663,12 @@ const deserializeAws_restJson1DeleteLaunchProfileMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2692,8 +2701,7 @@ const deserializeAws_restJson1DeleteStreamingImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2718,10 +2726,12 @@ const deserializeAws_restJson1DeleteStreamingImageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2754,8 +2764,7 @@ const deserializeAws_restJson1DeleteStreamingSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2780,10 +2789,12 @@ const deserializeAws_restJson1DeleteStreamingSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2816,8 +2827,7 @@ const deserializeAws_restJson1DeleteStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2842,10 +2852,12 @@ const deserializeAws_restJson1DeleteStudioCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2878,8 +2890,7 @@ const deserializeAws_restJson1DeleteStudioComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2904,10 +2915,12 @@ const deserializeAws_restJson1DeleteStudioComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2936,8 +2949,7 @@ const deserializeAws_restJson1DeleteStudioMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -2962,10 +2974,12 @@ const deserializeAws_restJson1DeleteStudioMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2998,8 +3012,7 @@ const deserializeAws_restJson1GetEulaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3024,10 +3037,12 @@ const deserializeAws_restJson1GetEulaCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3060,8 +3075,7 @@ const deserializeAws_restJson1GetLaunchProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3086,10 +3100,12 @@ const deserializeAws_restJson1GetLaunchProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3133,8 +3149,7 @@ const deserializeAws_restJson1GetLaunchProfileDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3159,10 +3174,12 @@ const deserializeAws_restJson1GetLaunchProfileDetailsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3198,8 +3215,7 @@ const deserializeAws_restJson1GetLaunchProfileInitializationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3224,10 +3240,12 @@ const deserializeAws_restJson1GetLaunchProfileInitializationCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3260,8 +3278,7 @@ const deserializeAws_restJson1GetLaunchProfileMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3286,10 +3303,12 @@ const deserializeAws_restJson1GetLaunchProfileMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3322,8 +3341,7 @@ const deserializeAws_restJson1GetStreamingImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3348,10 +3366,12 @@ const deserializeAws_restJson1GetStreamingImageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3384,8 +3404,7 @@ const deserializeAws_restJson1GetStreamingSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3410,10 +3429,12 @@ const deserializeAws_restJson1GetStreamingSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3446,8 +3467,7 @@ const deserializeAws_restJson1GetStreamingSessionStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3472,10 +3492,12 @@ const deserializeAws_restJson1GetStreamingSessionStreamCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3508,8 +3530,7 @@ const deserializeAws_restJson1GetStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3534,10 +3555,12 @@ const deserializeAws_restJson1GetStudioCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3570,8 +3593,7 @@ const deserializeAws_restJson1GetStudioComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3596,10 +3618,12 @@ const deserializeAws_restJson1GetStudioComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3632,8 +3656,7 @@ const deserializeAws_restJson1GetStudioMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3658,10 +3681,12 @@ const deserializeAws_restJson1GetStudioMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3698,8 +3723,7 @@ const deserializeAws_restJson1ListEulaAcceptancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3724,10 +3748,12 @@ const deserializeAws_restJson1ListEulaAcceptancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3764,8 +3790,7 @@ const deserializeAws_restJson1ListEulasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3790,10 +3815,12 @@ const deserializeAws_restJson1ListEulasCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3830,8 +3857,7 @@ const deserializeAws_restJson1ListLaunchProfileMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3856,10 +3882,12 @@ const deserializeAws_restJson1ListLaunchProfileMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3896,8 +3924,7 @@ const deserializeAws_restJson1ListLaunchProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3922,10 +3949,12 @@ const deserializeAws_restJson1ListLaunchProfilesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3962,8 +3991,7 @@ const deserializeAws_restJson1ListStreamingImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -3988,10 +4016,12 @@ const deserializeAws_restJson1ListStreamingImagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4028,8 +4058,7 @@ const deserializeAws_restJson1ListStreamingSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4054,10 +4083,12 @@ const deserializeAws_restJson1ListStreamingSessionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4094,8 +4125,7 @@ const deserializeAws_restJson1ListStudioComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4120,10 +4150,12 @@ const deserializeAws_restJson1ListStudioComponentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4160,8 +4192,7 @@ const deserializeAws_restJson1ListStudioMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4186,10 +4217,12 @@ const deserializeAws_restJson1ListStudioMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4226,8 +4259,7 @@ const deserializeAws_restJson1ListStudiosCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4252,10 +4284,12 @@ const deserializeAws_restJson1ListStudiosCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4288,8 +4322,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4314,10 +4347,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4346,8 +4381,7 @@ const deserializeAws_restJson1PutLaunchProfileMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4372,10 +4406,12 @@ const deserializeAws_restJson1PutLaunchProfileMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4404,8 +4440,7 @@ const deserializeAws_restJson1PutStudioMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4430,10 +4465,12 @@ const deserializeAws_restJson1PutStudioMembersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4466,8 +4503,7 @@ const deserializeAws_restJson1StartStreamingSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4492,10 +4528,12 @@ const deserializeAws_restJson1StartStreamingSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4528,8 +4566,7 @@ const deserializeAws_restJson1StartStudioSSOConfigurationRepairCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4554,10 +4591,12 @@ const deserializeAws_restJson1StartStudioSSOConfigurationRepairCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4590,8 +4629,7 @@ const deserializeAws_restJson1StopStreamingSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4616,10 +4654,12 @@ const deserializeAws_restJson1StopStreamingSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4648,8 +4688,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4674,10 +4713,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4706,8 +4747,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4732,10 +4772,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4768,8 +4810,7 @@ const deserializeAws_restJson1UpdateLaunchProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4794,10 +4835,12 @@ const deserializeAws_restJson1UpdateLaunchProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4830,8 +4873,7 @@ const deserializeAws_restJson1UpdateLaunchProfileMemberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4856,10 +4898,12 @@ const deserializeAws_restJson1UpdateLaunchProfileMemberCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4892,8 +4936,7 @@ const deserializeAws_restJson1UpdateStreamingImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4918,10 +4961,12 @@ const deserializeAws_restJson1UpdateStreamingImageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4954,8 +4999,7 @@ const deserializeAws_restJson1UpdateStudioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -4980,10 +5024,12 @@ const deserializeAws_restJson1UpdateStudioCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5016,8 +5062,7 @@ const deserializeAws_restJson1UpdateStudioComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.nimble#AccessDeniedException": @@ -5042,10 +5087,12 @@ const deserializeAws_restJson1UpdateStudioComponentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6491,7 +6538,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6517,6 +6564,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-opensearch/src/protocols/Aws_restJson1.ts b/clients/client-opensearch/src/protocols/Aws_restJson1.ts index 48a9a0a65b7a3..771668f80215d 100644 --- a/clients/client-opensearch/src/protocols/Aws_restJson1.ts +++ b/clients/client-opensearch/src/protocols/Aws_restJson1.ts @@ -1567,8 +1567,7 @@ const deserializeAws_restJson1AcceptInboundConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -1581,10 +1580,12 @@ const deserializeAws_restJson1AcceptInboundConnectionCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1613,8 +1614,7 @@ const deserializeAws_restJson1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -1630,10 +1630,12 @@ const deserializeAws_restJson1AddTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1666,8 +1668,7 @@ const deserializeAws_restJson1AssociatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -1689,10 +1690,12 @@ const deserializeAws_restJson1AssociatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1728,8 +1731,7 @@ const deserializeAws_restJson1CancelServiceSoftwareUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -1745,10 +1747,12 @@ const deserializeAws_restJson1CancelServiceSoftwareUpdateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1781,8 +1785,7 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -1807,10 +1810,12 @@ const deserializeAws_restJson1CreateDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1859,8 +1864,7 @@ const deserializeAws_restJson1CreateOutboundConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -1876,10 +1880,12 @@ const deserializeAws_restJson1CreateOutboundConnectionCommandError = async ( throw await deserializeAws_restJson1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1912,8 +1918,7 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -1938,10 +1943,12 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1974,8 +1981,7 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -1991,10 +1997,12 @@ const deserializeAws_restJson1DeleteDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2027,8 +2035,7 @@ const deserializeAws_restJson1DeleteInboundConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2038,10 +2045,12 @@ const deserializeAws_restJson1DeleteInboundConnectionCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2074,8 +2083,7 @@ const deserializeAws_restJson1DeleteOutboundConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2085,10 +2093,12 @@ const deserializeAws_restJson1DeleteOutboundConnectionCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2121,8 +2131,7 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -2144,10 +2153,12 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2180,8 +2191,7 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2197,10 +2207,12 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2237,8 +2249,7 @@ const deserializeAws_restJson1DescribeDomainAutoTunesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2254,10 +2265,12 @@ const deserializeAws_restJson1DescribeDomainAutoTunesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2293,8 +2306,7 @@ const deserializeAws_restJson1DescribeDomainChangeProgressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2310,10 +2322,12 @@ const deserializeAws_restJson1DescribeDomainChangeProgressCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2346,8 +2360,7 @@ const deserializeAws_restJson1DescribeDomainConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2363,10 +2376,12 @@ const deserializeAws_restJson1DescribeDomainConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2399,8 +2414,7 @@ const deserializeAws_restJson1DescribeDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2413,10 +2427,12 @@ const deserializeAws_restJson1DescribeDomainsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2453,8 +2469,7 @@ const deserializeAws_restJson1DescribeInboundConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2464,10 +2479,12 @@ const deserializeAws_restJson1DescribeInboundConnectionsCommandError = async ( throw await deserializeAws_restJson1InvalidPaginationTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2500,8 +2517,7 @@ const deserializeAws_restJson1DescribeInstanceTypeLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2523,10 +2539,12 @@ const deserializeAws_restJson1DescribeInstanceTypeLimitsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2563,8 +2581,7 @@ const deserializeAws_restJson1DescribeOutboundConnectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2574,10 +2591,12 @@ const deserializeAws_restJson1DescribeOutboundConnectionsCommandError = async ( throw await deserializeAws_restJson1InvalidPaginationTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2614,8 +2633,7 @@ const deserializeAws_restJson1DescribePackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -2634,10 +2652,12 @@ const deserializeAws_restJson1DescribePackagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2677,8 +2697,7 @@ const deserializeAws_restJson1DescribeReservedInstanceOfferingsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2694,10 +2713,12 @@ const deserializeAws_restJson1DescribeReservedInstanceOfferingsCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2734,8 +2755,7 @@ const deserializeAws_restJson1DescribeReservedInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -2751,10 +2771,12 @@ const deserializeAws_restJson1DescribeReservedInstancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2787,8 +2809,7 @@ const deserializeAws_restJson1DissociatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -2810,10 +2831,12 @@ const deserializeAws_restJson1DissociatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2846,8 +2869,7 @@ const deserializeAws_restJson1GetCompatibleVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2866,10 +2888,12 @@ const deserializeAws_restJson1GetCompatibleVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2913,8 +2937,7 @@ const deserializeAws_restJson1GetPackageVersionHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -2933,10 +2956,12 @@ const deserializeAws_restJson1GetPackageVersionHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2973,8 +2998,7 @@ const deserializeAws_restJson1GetUpgradeHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -2993,10 +3017,12 @@ const deserializeAws_restJson1GetUpgradeHistoryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3037,8 +3063,7 @@ const deserializeAws_restJson1GetUpgradeStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3057,10 +3082,12 @@ const deserializeAws_restJson1GetUpgradeStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3093,8 +3120,7 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3104,10 +3130,12 @@ const deserializeAws_restJson1ListDomainNamesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3147,8 +3175,7 @@ const deserializeAws_restJson1ListDomainsForPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -3167,10 +3194,12 @@ const deserializeAws_restJson1ListDomainsForPackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3207,8 +3236,7 @@ const deserializeAws_restJson1ListInstanceTypeDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3224,10 +3252,12 @@ const deserializeAws_restJson1ListInstanceTypeDetailsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3267,8 +3297,7 @@ const deserializeAws_restJson1ListPackagesForDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -3287,10 +3316,12 @@ const deserializeAws_restJson1ListPackagesForDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3323,8 +3354,7 @@ const deserializeAws_restJson1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3340,10 +3370,12 @@ const deserializeAws_restJson1ListTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3380,8 +3412,7 @@ const deserializeAws_restJson1ListVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3397,10 +3428,12 @@ const deserializeAws_restJson1ListVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3437,8 +3470,7 @@ const deserializeAws_restJson1PurchaseReservedInstanceOfferingCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -3460,10 +3492,12 @@ const deserializeAws_restJson1PurchaseReservedInstanceOfferingCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3496,8 +3530,7 @@ const deserializeAws_restJson1RejectInboundConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DisabledOperationException": case "com.amazonaws.opensearch#DisabledOperationException": @@ -3507,10 +3540,12 @@ const deserializeAws_restJson1RejectInboundConnectionCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3539,8 +3574,7 @@ const deserializeAws_restJson1RemoveTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3553,10 +3587,12 @@ const deserializeAws_restJson1RemoveTagsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3592,8 +3628,7 @@ const deserializeAws_restJson1StartServiceSoftwareUpdateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3609,10 +3644,12 @@ const deserializeAws_restJson1StartServiceSoftwareUpdateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3649,8 +3686,7 @@ const deserializeAws_restJson1UpdateDomainConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3672,10 +3708,12 @@ const deserializeAws_restJson1UpdateDomainConfigCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3708,8 +3746,7 @@ const deserializeAws_restJson1UpdatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.opensearch#AccessDeniedException": @@ -3731,10 +3768,12 @@ const deserializeAws_restJson1UpdatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3787,8 +3826,7 @@ const deserializeAws_restJson1UpgradeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BaseException": case "com.amazonaws.opensearch#BaseException": @@ -3810,10 +3848,12 @@ const deserializeAws_restJson1UpgradeDomainCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5794,7 +5834,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5820,6 +5860,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-opsworks/src/protocols/Aws_json1_1.ts b/clients/client-opsworks/src/protocols/Aws_json1_1.ts index 4c924f9891d7b..e246eb7556d20 100644 --- a/clients/client-opsworks/src/protocols/Aws_json1_1.ts +++ b/clients/client-opsworks/src/protocols/Aws_json1_1.ts @@ -1310,8 +1310,7 @@ const deserializeAws_json1_1AssignInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1321,10 +1320,12 @@ const deserializeAws_json1_1AssignInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1353,8 +1354,7 @@ const deserializeAws_json1_1AssignVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1364,10 +1364,12 @@ const deserializeAws_json1_1AssignVolumeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1396,8 +1398,7 @@ const deserializeAws_json1_1AssociateElasticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1407,10 +1408,12 @@ const deserializeAws_json1_1AssociateElasticIpCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1439,8 +1442,7 @@ const deserializeAws_json1_1AttachElasticLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1450,10 +1452,12 @@ const deserializeAws_json1_1AttachElasticLoadBalancerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1485,8 +1489,7 @@ const deserializeAws_json1_1CloneStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1496,10 +1499,12 @@ const deserializeAws_json1_1CloneStackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1531,8 +1536,7 @@ const deserializeAws_json1_1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1542,10 +1546,12 @@ const deserializeAws_json1_1CreateAppCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1583,7 @@ const deserializeAws_json1_1CreateDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1588,10 +1593,12 @@ const deserializeAws_json1_1CreateDeploymentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1623,8 +1630,7 @@ const deserializeAws_json1_1CreateInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1634,10 +1640,12 @@ const deserializeAws_json1_1CreateInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1669,8 +1677,7 @@ const deserializeAws_json1_1CreateLayerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1680,10 +1687,12 @@ const deserializeAws_json1_1CreateLayerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1715,18 +1724,19 @@ const deserializeAws_json1_1CreateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.opsworks#ValidationException": throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1758,18 +1768,19 @@ const deserializeAws_json1_1CreateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.opsworks#ValidationException": throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1798,8 +1809,7 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1809,10 +1819,12 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1841,8 +1853,7 @@ const deserializeAws_json1_1DeleteInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1852,10 +1863,12 @@ const deserializeAws_json1_1DeleteInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1884,8 +1897,7 @@ const deserializeAws_json1_1DeleteLayerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1895,10 +1907,12 @@ const deserializeAws_json1_1DeleteLayerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1927,8 +1941,7 @@ const deserializeAws_json1_1DeleteStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1938,10 +1951,12 @@ const deserializeAws_json1_1DeleteStackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1970,8 +1985,7 @@ const deserializeAws_json1_1DeleteUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -1981,10 +1995,12 @@ const deserializeAws_json1_1DeleteUserProfileCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2013,8 +2029,7 @@ const deserializeAws_json1_1DeregisterEcsClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2024,10 +2039,12 @@ const deserializeAws_json1_1DeregisterEcsClusterCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2056,8 +2073,7 @@ const deserializeAws_json1_1DeregisterElasticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2067,10 +2083,12 @@ const deserializeAws_json1_1DeregisterElasticIpCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2099,8 +2117,7 @@ const deserializeAws_json1_1DeregisterInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2110,10 +2127,12 @@ const deserializeAws_json1_1DeregisterInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2142,8 +2161,7 @@ const deserializeAws_json1_1DeregisterRdsDbInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2153,10 +2171,12 @@ const deserializeAws_json1_1DeregisterRdsDbInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2185,8 +2205,7 @@ const deserializeAws_json1_1DeregisterVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2196,10 +2215,12 @@ const deserializeAws_json1_1DeregisterVolumeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2231,8 +2252,7 @@ const deserializeAws_json1_1DescribeAgentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2242,10 +2262,12 @@ const deserializeAws_json1_1DescribeAgentVersionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2277,8 +2299,7 @@ const deserializeAws_json1_1DescribeAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2288,10 +2309,12 @@ const deserializeAws_json1_1DescribeAppsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2323,8 +2346,7 @@ const deserializeAws_json1_1DescribeCommandsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2334,10 +2356,12 @@ const deserializeAws_json1_1DescribeCommandsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2369,8 +2393,7 @@ const deserializeAws_json1_1DescribeDeploymentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2380,10 +2403,12 @@ const deserializeAws_json1_1DescribeDeploymentsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2415,8 +2440,7 @@ const deserializeAws_json1_1DescribeEcsClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2426,10 +2450,12 @@ const deserializeAws_json1_1DescribeEcsClustersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2461,8 +2487,7 @@ const deserializeAws_json1_1DescribeElasticIpsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2472,10 +2497,12 @@ const deserializeAws_json1_1DescribeElasticIpsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2507,8 +2534,7 @@ const deserializeAws_json1_1DescribeElasticLoadBalancersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2518,10 +2544,12 @@ const deserializeAws_json1_1DescribeElasticLoadBalancersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2553,8 +2581,7 @@ const deserializeAws_json1_1DescribeInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2564,10 +2591,12 @@ const deserializeAws_json1_1DescribeInstancesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2599,8 +2628,7 @@ const deserializeAws_json1_1DescribeLayersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2610,10 +2638,12 @@ const deserializeAws_json1_1DescribeLayersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2645,8 +2675,7 @@ const deserializeAws_json1_1DescribeLoadBasedAutoScalingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2656,10 +2685,12 @@ const deserializeAws_json1_1DescribeLoadBasedAutoScalingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2691,15 +2722,16 @@ const deserializeAws_json1_1DescribeMyUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2731,15 +2763,16 @@ const deserializeAws_json1_1DescribeOperatingSystemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2771,8 +2804,7 @@ const deserializeAws_json1_1DescribePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2782,10 +2814,12 @@ const deserializeAws_json1_1DescribePermissionsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2817,8 +2851,7 @@ const deserializeAws_json1_1DescribeRaidArraysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2828,10 +2861,12 @@ const deserializeAws_json1_1DescribeRaidArraysCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2863,8 +2898,7 @@ const deserializeAws_json1_1DescribeRdsDbInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2874,10 +2908,12 @@ const deserializeAws_json1_1DescribeRdsDbInstancesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2909,8 +2945,7 @@ const deserializeAws_json1_1DescribeServiceErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2920,10 +2955,12 @@ const deserializeAws_json1_1DescribeServiceErrorsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2955,8 +2992,7 @@ const deserializeAws_json1_1DescribeStackProvisioningParametersCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -2966,10 +3002,12 @@ const deserializeAws_json1_1DescribeStackProvisioningParametersCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3001,8 +3039,7 @@ const deserializeAws_json1_1DescribeStacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3012,10 +3049,12 @@ const deserializeAws_json1_1DescribeStacksCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3047,8 +3086,7 @@ const deserializeAws_json1_1DescribeStackSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3058,10 +3096,12 @@ const deserializeAws_json1_1DescribeStackSummaryCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3093,8 +3133,7 @@ const deserializeAws_json1_1DescribeTimeBasedAutoScalingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3104,10 +3143,12 @@ const deserializeAws_json1_1DescribeTimeBasedAutoScalingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3139,8 +3180,7 @@ const deserializeAws_json1_1DescribeUserProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3150,10 +3190,12 @@ const deserializeAws_json1_1DescribeUserProfilesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3185,8 +3227,7 @@ const deserializeAws_json1_1DescribeVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3196,10 +3237,12 @@ const deserializeAws_json1_1DescribeVolumesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3228,18 +3271,19 @@ const deserializeAws_json1_1DetachElasticLoadBalancerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3268,8 +3312,7 @@ const deserializeAws_json1_1DisassociateElasticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3279,10 +3322,12 @@ const deserializeAws_json1_1DisassociateElasticIpCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3314,8 +3359,7 @@ const deserializeAws_json1_1GetHostnameSuggestionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3325,10 +3369,12 @@ const deserializeAws_json1_1GetHostnameSuggestionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3360,8 +3406,7 @@ const deserializeAws_json1_1GrantAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3371,10 +3416,12 @@ const deserializeAws_json1_1GrantAccessCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3406,8 +3453,7 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3417,10 +3463,12 @@ const deserializeAws_json1_1ListTagsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3449,8 +3497,7 @@ const deserializeAws_json1_1RebootInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3460,10 +3507,12 @@ const deserializeAws_json1_1RebootInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3495,8 +3544,7 @@ const deserializeAws_json1_1RegisterEcsClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3506,10 +3554,12 @@ const deserializeAws_json1_1RegisterEcsClusterCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3541,8 +3591,7 @@ const deserializeAws_json1_1RegisterElasticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3552,10 +3601,12 @@ const deserializeAws_json1_1RegisterElasticIpCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3587,8 +3638,7 @@ const deserializeAws_json1_1RegisterInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3598,10 +3648,12 @@ const deserializeAws_json1_1RegisterInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3630,8 +3682,7 @@ const deserializeAws_json1_1RegisterRdsDbInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3641,10 +3692,12 @@ const deserializeAws_json1_1RegisterRdsDbInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3676,8 +3729,7 @@ const deserializeAws_json1_1RegisterVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3687,10 +3739,12 @@ const deserializeAws_json1_1RegisterVolumeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3719,8 +3773,7 @@ const deserializeAws_json1_1SetLoadBasedAutoScalingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3730,10 +3783,12 @@ const deserializeAws_json1_1SetLoadBasedAutoScalingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3762,8 +3817,7 @@ const deserializeAws_json1_1SetPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3773,10 +3827,12 @@ const deserializeAws_json1_1SetPermissionCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3805,8 +3861,7 @@ const deserializeAws_json1_1SetTimeBasedAutoScalingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3816,10 +3871,12 @@ const deserializeAws_json1_1SetTimeBasedAutoScalingCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3848,8 +3905,7 @@ const deserializeAws_json1_1StartInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3859,10 +3915,12 @@ const deserializeAws_json1_1StartInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3891,8 +3949,7 @@ const deserializeAws_json1_1StartStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3902,10 +3959,12 @@ const deserializeAws_json1_1StartStackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3934,8 +3993,7 @@ const deserializeAws_json1_1StopInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3945,10 +4003,12 @@ const deserializeAws_json1_1StopInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3977,8 +4037,7 @@ const deserializeAws_json1_1StopStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -3988,10 +4047,12 @@ const deserializeAws_json1_1StopStackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4020,8 +4081,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4031,10 +4091,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4063,8 +4125,7 @@ const deserializeAws_json1_1UnassignInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4074,10 +4135,12 @@ const deserializeAws_json1_1UnassignInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4106,8 +4169,7 @@ const deserializeAws_json1_1UnassignVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4117,10 +4179,12 @@ const deserializeAws_json1_1UnassignVolumeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4149,8 +4213,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4160,10 +4223,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4192,8 +4257,7 @@ const deserializeAws_json1_1UpdateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4203,10 +4267,12 @@ const deserializeAws_json1_1UpdateAppCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4235,8 +4301,7 @@ const deserializeAws_json1_1UpdateElasticIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4246,10 +4311,12 @@ const deserializeAws_json1_1UpdateElasticIpCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4278,8 +4345,7 @@ const deserializeAws_json1_1UpdateInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4289,10 +4355,12 @@ const deserializeAws_json1_1UpdateInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4321,8 +4389,7 @@ const deserializeAws_json1_1UpdateLayerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4332,10 +4399,12 @@ const deserializeAws_json1_1UpdateLayerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4364,18 +4433,19 @@ const deserializeAws_json1_1UpdateMyUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ValidationException": case "com.amazonaws.opsworks#ValidationException": throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4404,8 +4474,7 @@ const deserializeAws_json1_1UpdateRdsDbInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4415,10 +4484,12 @@ const deserializeAws_json1_1UpdateRdsDbInstanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4447,8 +4518,7 @@ const deserializeAws_json1_1UpdateStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4458,10 +4528,12 @@ const deserializeAws_json1_1UpdateStackCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4490,8 +4562,7 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4501,10 +4572,12 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4533,8 +4606,7 @@ const deserializeAws_json1_1UpdateVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworks#ResourceNotFoundException": @@ -4544,10 +4616,12 @@ const deserializeAws_json1_1UpdateVolumeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7435,7 +7509,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7461,6 +7535,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-opsworkscm/src/protocols/Aws_json1_1.ts b/clients/client-opsworkscm/src/protocols/Aws_json1_1.ts index 2a02f29cc7829..2d5fcb4863b57 100644 --- a/clients/client-opsworkscm/src/protocols/Aws_json1_1.ts +++ b/clients/client-opsworkscm/src/protocols/Aws_json1_1.ts @@ -377,8 +377,7 @@ const deserializeAws_json1_1AssociateNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -391,10 +390,12 @@ const deserializeAws_json1_1AssociateNodeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -426,8 +427,7 @@ const deserializeAws_json1_1CreateBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -443,10 +443,12 @@ const deserializeAws_json1_1CreateBackupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -478,8 +480,7 @@ const deserializeAws_json1_1CreateServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededException": case "com.amazonaws.opsworkscm#LimitExceededException": @@ -495,10 +496,12 @@ const deserializeAws_json1_1CreateServerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -530,8 +533,7 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -544,10 +546,12 @@ const deserializeAws_json1_1DeleteBackupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -579,8 +583,7 @@ const deserializeAws_json1_1DeleteServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -593,10 +596,12 @@ const deserializeAws_json1_1DeleteServerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -628,15 +633,16 @@ const deserializeAws_json1_1DescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -668,8 +674,7 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.opsworkscm#InvalidNextTokenException": @@ -682,10 +687,12 @@ const deserializeAws_json1_1DescribeBackupsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -717,8 +724,7 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.opsworkscm#InvalidNextTokenException": @@ -731,10 +737,12 @@ const deserializeAws_json1_1DescribeEventsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -766,8 +774,7 @@ const deserializeAws_json1_1DescribeNodeAssociationStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworkscm#ResourceNotFoundException": @@ -777,10 +784,12 @@ const deserializeAws_json1_1DescribeNodeAssociationStatusCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -812,8 +821,7 @@ const deserializeAws_json1_1DescribeServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.opsworkscm#InvalidNextTokenException": @@ -826,10 +834,12 @@ const deserializeAws_json1_1DescribeServersCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -861,8 +871,7 @@ const deserializeAws_json1_1DisassociateNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -875,10 +884,12 @@ const deserializeAws_json1_1DisassociateNodeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -910,8 +921,7 @@ const deserializeAws_json1_1ExportServerEngineAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -924,10 +934,12 @@ const deserializeAws_json1_1ExportServerEngineAttributeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,8 +971,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.opsworkscm#ResourceNotFoundException": @@ -970,10 +981,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1005,8 +1018,7 @@ const deserializeAws_json1_1RestoreServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1019,10 +1031,12 @@ const deserializeAws_json1_1RestoreServerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1054,8 +1068,7 @@ const deserializeAws_json1_1StartMaintenanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1068,10 +1081,12 @@ const deserializeAws_json1_1StartMaintenanceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1103,8 +1118,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1117,10 +1131,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1152,8 +1168,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1166,10 +1181,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1201,8 +1218,7 @@ const deserializeAws_json1_1UpdateServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1215,10 +1231,12 @@ const deserializeAws_json1_1UpdateServerCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1250,8 +1268,7 @@ const deserializeAws_json1_1UpdateServerEngineAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.opsworkscm#InvalidStateException": @@ -1264,10 +1281,12 @@ const deserializeAws_json1_1UpdateServerEngineAttributesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2097,7 +2116,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2123,6 +2142,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-organizations/src/protocols/Aws_json1_1.ts b/clients/client-organizations/src/protocols/Aws_json1_1.ts index ac8e64c13b984..f8d65069cbf39 100644 --- a/clients/client-organizations/src/protocols/Aws_json1_1.ts +++ b/clients/client-organizations/src/protocols/Aws_json1_1.ts @@ -998,8 +998,7 @@ const deserializeAws_json1_1AcceptHandshakeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1036,10 +1035,12 @@ const deserializeAws_json1_1AcceptHandshakeCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1068,8 +1069,7 @@ const deserializeAws_json1_1AttachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1112,10 +1112,12 @@ const deserializeAws_json1_1AttachPolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1147,8 +1149,7 @@ const deserializeAws_json1_1CancelHandshakeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1176,10 +1177,12 @@ const deserializeAws_json1_1CancelHandshakeCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1208,8 +1211,7 @@ const deserializeAws_json1_1CloseAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1246,10 +1248,12 @@ const deserializeAws_json1_1CloseAccountCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1281,8 +1285,7 @@ const deserializeAws_json1_1CreateAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1313,10 +1316,12 @@ const deserializeAws_json1_1CreateAccountCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1348,8 +1353,7 @@ const deserializeAws_json1_1CreateGovCloudAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1380,10 +1384,12 @@ const deserializeAws_json1_1CreateGovCloudAccountCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1415,8 +1421,7 @@ const deserializeAws_json1_1CreateOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1444,10 +1449,12 @@ const deserializeAws_json1_1CreateOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1479,8 +1486,7 @@ const deserializeAws_json1_1CreateOrganizationalUnitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1511,10 +1517,12 @@ const deserializeAws_json1_1CreateOrganizationalUnitCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1546,8 +1554,7 @@ const deserializeAws_json1_1CreatePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1584,10 +1591,12 @@ const deserializeAws_json1_1CreatePolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1619,8 +1628,7 @@ const deserializeAws_json1_1DeclineHandshakeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1648,10 +1656,12 @@ const deserializeAws_json1_1DeclineHandshakeCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1680,8 +1690,7 @@ const deserializeAws_json1_1DeleteOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1706,10 +1715,12 @@ const deserializeAws_json1_1DeleteOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1738,8 +1749,7 @@ const deserializeAws_json1_1DeleteOrganizationalUnitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1767,10 +1777,12 @@ const deserializeAws_json1_1DeleteOrganizationalUnitCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1799,8 +1811,7 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1831,10 +1842,12 @@ const deserializeAws_json1_1DeletePolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1863,8 +1876,7 @@ const deserializeAws_json1_1DeregisterDelegatedAdministratorCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1898,10 +1910,12 @@ const deserializeAws_json1_1DeregisterDelegatedAdministratorCommandError = async throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1933,8 +1947,7 @@ const deserializeAws_json1_1DescribeAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -1956,10 +1969,12 @@ const deserializeAws_json1_1DescribeAccountCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1991,8 +2006,7 @@ const deserializeAws_json1_1DescribeCreateAccountStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2017,10 +2031,12 @@ const deserializeAws_json1_1DescribeCreateAccountStatusCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2052,8 +2068,7 @@ const deserializeAws_json1_1DescribeEffectivePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2084,10 +2099,12 @@ const deserializeAws_json1_1DescribeEffectivePolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2119,8 +2136,7 @@ const deserializeAws_json1_1DescribeHandshakeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2142,10 +2158,12 @@ const deserializeAws_json1_1DescribeHandshakeCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2177,8 +2195,7 @@ const deserializeAws_json1_1DescribeOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2197,10 +2214,12 @@ const deserializeAws_json1_1DescribeOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2232,8 +2251,7 @@ const deserializeAws_json1_1DescribeOrganizationalUnitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2255,10 +2273,12 @@ const deserializeAws_json1_1DescribeOrganizationalUnitCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2290,8 +2310,7 @@ const deserializeAws_json1_1DescribePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2316,10 +2335,12 @@ const deserializeAws_json1_1DescribePolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2348,8 +2369,7 @@ const deserializeAws_json1_1DetachPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2389,10 +2409,12 @@ const deserializeAws_json1_1DetachPolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2421,8 +2443,7 @@ const deserializeAws_json1_1DisableAWSServiceAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2450,10 +2471,12 @@ const deserializeAws_json1_1DisableAWSServiceAccessCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2485,8 +2508,7 @@ const deserializeAws_json1_1DisablePolicyTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2523,10 +2545,12 @@ const deserializeAws_json1_1DisablePolicyTypeCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2558,8 +2582,7 @@ const deserializeAws_json1_1EnableAllFeaturesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2584,10 +2607,12 @@ const deserializeAws_json1_1EnableAllFeaturesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2616,8 +2641,7 @@ const deserializeAws_json1_1EnableAWSServiceAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2645,10 +2669,12 @@ const deserializeAws_json1_1EnableAWSServiceAccessCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2680,8 +2706,7 @@ const deserializeAws_json1_1EnablePolicyTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2721,10 +2746,12 @@ const deserializeAws_json1_1EnablePolicyTypeCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2756,8 +2783,7 @@ const deserializeAws_json1_1InviteAccountToOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2794,10 +2820,12 @@ const deserializeAws_json1_1InviteAccountToOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2826,8 +2854,7 @@ const deserializeAws_json1_1LeaveOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2858,10 +2885,12 @@ const deserializeAws_json1_1LeaveOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2893,8 +2922,7 @@ const deserializeAws_json1_1ListAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2913,10 +2941,12 @@ const deserializeAws_json1_1ListAccountsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2948,8 +2978,7 @@ const deserializeAws_json1_1ListAccountsForParentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -2971,10 +3000,12 @@ const deserializeAws_json1_1ListAccountsForParentCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3006,8 +3037,7 @@ const deserializeAws_json1_1ListAWSServiceAccessForOrganizationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3032,10 +3062,12 @@ const deserializeAws_json1_1ListAWSServiceAccessForOrganizationCommandError = as throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3067,8 +3099,7 @@ const deserializeAws_json1_1ListChildrenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3090,10 +3121,12 @@ const deserializeAws_json1_1ListChildrenCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3125,8 +3158,7 @@ const deserializeAws_json1_1ListCreateAccountStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3148,10 +3180,12 @@ const deserializeAws_json1_1ListCreateAccountStatusCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3183,8 +3217,7 @@ const deserializeAws_json1_1ListDelegatedAdministratorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3209,10 +3242,12 @@ const deserializeAws_json1_1ListDelegatedAdministratorsCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3244,8 +3279,7 @@ const deserializeAws_json1_1ListDelegatedServicesForAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3276,10 +3310,12 @@ const deserializeAws_json1_1ListDelegatedServicesForAccountCommandError = async throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3311,8 +3347,7 @@ const deserializeAws_json1_1ListHandshakesForAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3331,10 +3366,12 @@ const deserializeAws_json1_1ListHandshakesForAccountCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3366,8 +3403,7 @@ const deserializeAws_json1_1ListHandshakesForOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3389,10 +3425,12 @@ const deserializeAws_json1_1ListHandshakesForOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3424,8 +3462,7 @@ const deserializeAws_json1_1ListOrganizationalUnitsForParentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3447,10 +3484,12 @@ const deserializeAws_json1_1ListOrganizationalUnitsForParentCommandError = async throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3482,8 +3521,7 @@ const deserializeAws_json1_1ListParentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3505,10 +3543,12 @@ const deserializeAws_json1_1ListParentsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3540,8 +3580,7 @@ const deserializeAws_json1_1ListPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3563,10 +3602,12 @@ const deserializeAws_json1_1ListPoliciesCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3598,8 +3639,7 @@ const deserializeAws_json1_1ListPoliciesForTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3624,10 +3664,12 @@ const deserializeAws_json1_1ListPoliciesForTargetCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3659,8 +3701,7 @@ const deserializeAws_json1_1ListRootsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3679,10 +3720,12 @@ const deserializeAws_json1_1ListRootsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3714,8 +3757,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3737,10 +3779,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3772,8 +3816,7 @@ const deserializeAws_json1_1ListTargetsForPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3798,10 +3841,12 @@ const deserializeAws_json1_1ListTargetsForPolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3830,8 +3875,7 @@ const deserializeAws_json1_1MoveAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3865,10 +3909,12 @@ const deserializeAws_json1_1MoveAccountCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3897,8 +3943,7 @@ const deserializeAws_json1_1RegisterDelegatedAdministratorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3932,10 +3977,12 @@ const deserializeAws_json1_1RegisterDelegatedAdministratorCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3964,8 +4011,7 @@ const deserializeAws_json1_1RemoveAccountFromOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -3996,10 +4042,12 @@ const deserializeAws_json1_1RemoveAccountFromOrganizationCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4028,8 +4076,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -4057,10 +4104,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4089,8 +4138,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -4118,10 +4166,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4153,8 +4203,7 @@ const deserializeAws_json1_1UpdateOrganizationalUnitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -4182,10 +4231,12 @@ const deserializeAws_json1_1UpdateOrganizationalUnitCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4217,8 +4268,7 @@ const deserializeAws_json1_1UpdatePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.organizations#AccessDeniedException": @@ -4258,10 +4308,12 @@ const deserializeAws_json1_1UpdatePolicyCommandError = async ( throw await deserializeAws_json1_1UnsupportedAPIEndpointExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6680,7 +6732,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -6706,6 +6758,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-outposts/src/protocols/Aws_restJson1.ts b/clients/client-outposts/src/protocols/Aws_restJson1.ts index c2b447db7d81e..dad0738a0e1f1 100644 --- a/clients/client-outposts/src/protocols/Aws_restJson1.ts +++ b/clients/client-outposts/src/protocols/Aws_restJson1.ts @@ -935,8 +935,7 @@ const deserializeAws_restJson1CancelOrderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -955,10 +954,12 @@ const deserializeAws_restJson1CancelOrderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -991,8 +992,7 @@ const deserializeAws_restJson1CreateOrderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1014,10 +1014,12 @@ const deserializeAws_restJson1CreateOrderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1050,8 +1052,7 @@ const deserializeAws_restJson1CreateOutpostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1073,10 +1074,12 @@ const deserializeAws_restJson1CreateOutpostCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1109,8 +1112,7 @@ const deserializeAws_restJson1CreateSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1129,10 +1131,12 @@ const deserializeAws_restJson1CreateSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1161,8 +1165,7 @@ const deserializeAws_restJson1DeleteOutpostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1181,10 +1184,12 @@ const deserializeAws_restJson1DeleteOutpostCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1213,8 +1218,7 @@ const deserializeAws_restJson1DeleteSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1233,10 +1237,12 @@ const deserializeAws_restJson1DeleteSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1269,8 +1275,7 @@ const deserializeAws_restJson1GetCatalogItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -1283,10 +1288,12 @@ const deserializeAws_restJson1GetCatalogItemCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1323,8 +1330,7 @@ const deserializeAws_restJson1GetConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1340,10 +1346,12 @@ const deserializeAws_restJson1GetConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1376,8 +1384,7 @@ const deserializeAws_restJson1GetOrderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -1390,10 +1397,12 @@ const deserializeAws_restJson1GetOrderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1426,8 +1435,7 @@ const deserializeAws_restJson1GetOutpostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1443,10 +1451,12 @@ const deserializeAws_restJson1GetOutpostCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1491,8 +1501,7 @@ const deserializeAws_restJson1GetOutpostInstanceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1508,10 +1517,12 @@ const deserializeAws_restJson1GetOutpostInstanceTypesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1555,7 @@ const deserializeAws_restJson1GetSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1561,10 +1571,12 @@ const deserializeAws_restJson1GetSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1605,8 +1617,7 @@ const deserializeAws_restJson1GetSiteAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1622,10 +1633,12 @@ const deserializeAws_restJson1GetSiteAddressCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1662,8 +1675,7 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1679,10 +1691,12 @@ const deserializeAws_restJson1ListAssetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1719,8 +1733,7 @@ const deserializeAws_restJson1ListCatalogItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -1733,10 +1746,12 @@ const deserializeAws_restJson1ListCatalogItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1773,8 +1788,7 @@ const deserializeAws_restJson1ListOrdersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1790,10 +1804,12 @@ const deserializeAws_restJson1ListOrdersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1830,8 +1846,7 @@ const deserializeAws_restJson1ListOutpostsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1844,10 +1859,12 @@ const deserializeAws_restJson1ListOutpostsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1884,8 +1901,7 @@ const deserializeAws_restJson1ListSitesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -1898,10 +1914,12 @@ const deserializeAws_restJson1ListSitesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1934,8 +1952,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -1948,10 +1965,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1988,8 +2007,7 @@ const deserializeAws_restJson1StartConnectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -2005,10 +2023,12 @@ const deserializeAws_restJson1StartConnectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2037,8 +2057,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -2051,10 +2070,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2083,8 +2104,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.outposts#InternalServerException": @@ -2097,10 +2117,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2155,7 @@ const deserializeAws_restJson1UpdateOutpostCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -2153,10 +2174,12 @@ const deserializeAws_restJson1UpdateOutpostCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2189,8 +2212,7 @@ const deserializeAws_restJson1UpdateSiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -2209,10 +2231,12 @@ const deserializeAws_restJson1UpdateSiteCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2249,8 +2273,7 @@ const deserializeAws_restJson1UpdateSiteAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -2269,10 +2292,12 @@ const deserializeAws_restJson1UpdateSiteAddressCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2305,8 +2330,7 @@ const deserializeAws_restJson1UpdateSiteRackPhysicalPropertiesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.outposts#AccessDeniedException": @@ -2325,10 +2349,12 @@ const deserializeAws_restJson1UpdateSiteRackPhysicalPropertiesCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2907,7 +2933,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2933,6 +2959,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-panorama/src/protocols/Aws_restJson1.ts b/clients/client-panorama/src/protocols/Aws_restJson1.ts index 8bdd5abb0c296..ea726a72b2209 100644 --- a/clients/client-panorama/src/protocols/Aws_restJson1.ts +++ b/clients/client-panorama/src/protocols/Aws_restJson1.ts @@ -1235,8 +1235,7 @@ const deserializeAws_restJson1CreateApplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1252,10 +1251,12 @@ const deserializeAws_restJson1CreateApplicationInstanceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1288,8 +1289,7 @@ const deserializeAws_restJson1CreateJobForDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1308,10 +1308,12 @@ const deserializeAws_restJson1CreateJobForDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1344,8 +1346,7 @@ const deserializeAws_restJson1CreateNodeFromTemplateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1361,10 +1362,12 @@ const deserializeAws_restJson1CreateNodeFromTemplateJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1405,8 +1408,7 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1422,10 +1424,12 @@ const deserializeAws_restJson1CreatePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1458,8 +1462,7 @@ const deserializeAws_restJson1CreatePackageImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1475,10 +1478,12 @@ const deserializeAws_restJson1CreatePackageImportJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1511,8 +1516,7 @@ const deserializeAws_restJson1DeleteDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1531,10 +1535,12 @@ const deserializeAws_restJson1DeleteDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1563,8 +1569,7 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1583,10 +1588,12 @@ const deserializeAws_restJson1DeletePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1615,8 +1622,7 @@ const deserializeAws_restJson1DeregisterPackageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1635,10 +1641,12 @@ const deserializeAws_restJson1DeregisterPackageVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1731,7 @@ const deserializeAws_restJson1DescribeApplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1743,10 +1750,12 @@ const deserializeAws_restJson1DescribeApplicationInstanceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1810,8 +1819,7 @@ const deserializeAws_restJson1DescribeApplicationInstanceDetailsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1830,10 +1838,12 @@ const deserializeAws_restJson1DescribeApplicationInstanceDetailsCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1934,8 +1944,7 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -1951,10 +1960,12 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2015,8 +2026,7 @@ const deserializeAws_restJson1DescribeDeviceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2035,10 +2045,12 @@ const deserializeAws_restJson1DescribeDeviceJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2123,8 +2135,7 @@ const deserializeAws_restJson1DescribeNodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2143,10 +2154,12 @@ const deserializeAws_restJson1DescribeNodeCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2223,8 +2236,7 @@ const deserializeAws_restJson1DescribeNodeFromTemplateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2240,10 +2252,12 @@ const deserializeAws_restJson1DescribeNodeFromTemplateJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2307,8 +2321,7 @@ const deserializeAws_restJson1DescribePackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2327,10 +2340,12 @@ const deserializeAws_restJson1DescribePackageCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2403,8 +2418,7 @@ const deserializeAws_restJson1DescribePackageImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2420,10 +2434,12 @@ const deserializeAws_restJson1DescribePackageImportJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2492,8 +2508,7 @@ const deserializeAws_restJson1DescribePackageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2512,10 +2527,12 @@ const deserializeAws_restJson1DescribePackageVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2552,8 +2569,7 @@ const deserializeAws_restJson1ListApplicationInstanceDependenciesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2563,10 +2579,12 @@ const deserializeAws_restJson1ListApplicationInstanceDependenciesCommandError = throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2603,8 +2621,7 @@ const deserializeAws_restJson1ListApplicationInstanceNodeInstancesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2614,10 +2631,12 @@ const deserializeAws_restJson1ListApplicationInstanceNodeInstancesCommandError = throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2654,8 +2673,7 @@ const deserializeAws_restJson1ListApplicationInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2665,10 +2683,12 @@ const deserializeAws_restJson1ListApplicationInstancesCommandError = async ( throw await deserializeAws_restJson1InternalServerExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2705,8 +2725,7 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2722,10 +2741,12 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2762,8 +2783,7 @@ const deserializeAws_restJson1ListDevicesJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2782,10 +2802,12 @@ const deserializeAws_restJson1ListDevicesJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2822,8 +2844,7 @@ const deserializeAws_restJson1ListNodeFromTemplateJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2839,10 +2860,12 @@ const deserializeAws_restJson1ListNodeFromTemplateJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2879,8 +2902,7 @@ const deserializeAws_restJson1ListNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.panorama#ConflictException": @@ -2893,10 +2915,12 @@ const deserializeAws_restJson1ListNodesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2933,8 +2957,7 @@ const deserializeAws_restJson1ListPackageImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -2950,10 +2973,12 @@ const deserializeAws_restJson1ListPackageImportJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2990,8 +3015,7 @@ const deserializeAws_restJson1ListPackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -3010,10 +3034,12 @@ const deserializeAws_restJson1ListPackagesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3046,8 +3072,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.panorama#InternalServerException": @@ -3060,10 +3085,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3112,8 +3139,7 @@ const deserializeAws_restJson1ProvisionDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -3132,10 +3158,12 @@ const deserializeAws_restJson1ProvisionDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3164,8 +3192,7 @@ const deserializeAws_restJson1RegisterPackageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -3181,10 +3208,12 @@ const deserializeAws_restJson1RegisterPackageVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3213,8 +3242,7 @@ const deserializeAws_restJson1RemoveApplicationInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -3233,10 +3261,12 @@ const deserializeAws_restJson1RemoveApplicationInstanceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3265,8 +3295,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.panorama#InternalServerException": @@ -3279,10 +3308,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3311,8 +3342,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.panorama#InternalServerException": @@ -3325,10 +3355,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3361,8 +3393,7 @@ const deserializeAws_restJson1UpdateDeviceMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.panorama#AccessDeniedException": @@ -3381,10 +3412,12 @@ const deserializeAws_restJson1UpdateDeviceMetadataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4476,7 +4509,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4502,6 +4535,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-personalize-events/src/protocols/Aws_restJson1.ts b/clients/client-personalize-events/src/protocols/Aws_restJson1.ts index 22bdc2ae4054e..1f597c6ffa11a 100644 --- a/clients/client-personalize-events/src/protocols/Aws_restJson1.ts +++ b/clients/client-personalize-events/src/protocols/Aws_restJson1.ts @@ -128,18 +128,19 @@ const deserializeAws_restJson1PutEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalizeevents#InvalidInputException": throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -168,8 +169,7 @@ const deserializeAws_restJson1PutItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalizeevents#InvalidInputException": @@ -182,10 +182,12 @@ const deserializeAws_restJson1PutItemsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -214,8 +216,7 @@ const deserializeAws_restJson1PutUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalizeevents#InvalidInputException": @@ -228,10 +229,12 @@ const deserializeAws_restJson1PutUsersCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -399,7 +402,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -425,6 +428,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts b/clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts index f764dd6a55053..2005ecbed6068 100644 --- a/clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-personalize-runtime/src/protocols/Aws_restJson1.ts @@ -118,8 +118,7 @@ const deserializeAws_restJson1GetPersonalizedRankingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalizeruntime#InvalidInputException": @@ -129,10 +128,12 @@ const deserializeAws_restJson1GetPersonalizedRankingCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -169,8 +170,7 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalizeruntime#InvalidInputException": @@ -180,10 +180,12 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -312,7 +314,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -338,6 +340,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-personalize/src/protocols/Aws_json1_1.ts b/clients/client-personalize/src/protocols/Aws_json1_1.ts index ab3bd3b29aa80..d6b82f8fa508e 100644 --- a/clients/client-personalize/src/protocols/Aws_json1_1.ts +++ b/clients/client-personalize/src/protocols/Aws_json1_1.ts @@ -1130,8 +1130,7 @@ const deserializeAws_json1_1CreateBatchInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1153,10 +1152,12 @@ const deserializeAws_json1_1CreateBatchInferenceJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1188,8 +1189,7 @@ const deserializeAws_json1_1CreateBatchSegmentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1211,10 +1211,12 @@ const deserializeAws_json1_1CreateBatchSegmentJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1246,8 +1248,7 @@ const deserializeAws_json1_1CreateCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1269,10 +1270,12 @@ const deserializeAws_json1_1CreateCampaignCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,8 +1307,7 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1327,10 +1329,12 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1362,8 +1366,7 @@ const deserializeAws_json1_1CreateDatasetExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1385,10 +1388,12 @@ const deserializeAws_json1_1CreateDatasetExportJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1420,8 +1425,7 @@ const deserializeAws_json1_1CreateDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1437,10 +1441,12 @@ const deserializeAws_json1_1CreateDatasetGroupCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1472,8 +1478,7 @@ const deserializeAws_json1_1CreateDatasetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1495,10 +1500,12 @@ const deserializeAws_json1_1CreateDatasetImportJobCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1530,8 +1537,7 @@ const deserializeAws_json1_1CreateEventTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1553,10 +1559,12 @@ const deserializeAws_json1_1CreateEventTrackerCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1588,8 +1596,7 @@ const deserializeAws_json1_1CreateFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1608,10 +1615,12 @@ const deserializeAws_json1_1CreateFilterCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1643,8 +1652,7 @@ const deserializeAws_json1_1CreateRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1666,10 +1674,12 @@ const deserializeAws_json1_1CreateRecommenderCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1701,8 +1711,7 @@ const deserializeAws_json1_1CreateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1715,10 +1724,12 @@ const deserializeAws_json1_1CreateSchemaCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1750,8 +1761,7 @@ const deserializeAws_json1_1CreateSolutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1773,10 +1783,12 @@ const deserializeAws_json1_1CreateSolutionCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1808,8 +1820,7 @@ const deserializeAws_json1_1CreateSolutionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1828,10 +1839,12 @@ const deserializeAws_json1_1CreateSolutionVersionCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1860,8 +1873,7 @@ const deserializeAws_json1_1DeleteCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1874,10 +1886,12 @@ const deserializeAws_json1_1DeleteCampaignCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1906,8 +1920,7 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1920,10 +1933,12 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1952,8 +1967,7 @@ const deserializeAws_json1_1DeleteDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -1966,10 +1980,12 @@ const deserializeAws_json1_1DeleteDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1998,8 +2014,7 @@ const deserializeAws_json1_1DeleteEventTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2012,10 +2027,12 @@ const deserializeAws_json1_1DeleteEventTrackerCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,8 +2061,7 @@ const deserializeAws_json1_1DeleteFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2058,10 +2074,12 @@ const deserializeAws_json1_1DeleteFilterCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2090,8 +2108,7 @@ const deserializeAws_json1_1DeleteRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2104,10 +2121,12 @@ const deserializeAws_json1_1DeleteRecommenderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2136,8 +2155,7 @@ const deserializeAws_json1_1DeleteSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2150,10 +2168,12 @@ const deserializeAws_json1_1DeleteSchemaCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2202,7 @@ const deserializeAws_json1_1DeleteSolutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2196,10 +2215,12 @@ const deserializeAws_json1_1DeleteSolutionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2231,8 +2252,7 @@ const deserializeAws_json1_1DescribeAlgorithmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2242,10 +2262,12 @@ const deserializeAws_json1_1DescribeAlgorithmCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2277,8 +2299,7 @@ const deserializeAws_json1_1DescribeBatchInferenceJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2288,10 +2309,12 @@ const deserializeAws_json1_1DescribeBatchInferenceJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2323,8 +2346,7 @@ const deserializeAws_json1_1DescribeBatchSegmentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2334,10 +2356,12 @@ const deserializeAws_json1_1DescribeBatchSegmentJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2369,8 +2393,7 @@ const deserializeAws_json1_1DescribeCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2380,10 +2403,12 @@ const deserializeAws_json1_1DescribeCampaignCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2415,8 +2440,7 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2426,10 +2450,12 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2461,8 +2487,7 @@ const deserializeAws_json1_1DescribeDatasetExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2472,10 +2497,12 @@ const deserializeAws_json1_1DescribeDatasetExportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2507,8 +2534,7 @@ const deserializeAws_json1_1DescribeDatasetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2518,10 +2544,12 @@ const deserializeAws_json1_1DescribeDatasetGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2553,8 +2581,7 @@ const deserializeAws_json1_1DescribeDatasetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2564,10 +2591,12 @@ const deserializeAws_json1_1DescribeDatasetImportJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2599,8 +2628,7 @@ const deserializeAws_json1_1DescribeEventTrackerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2610,10 +2638,12 @@ const deserializeAws_json1_1DescribeEventTrackerCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2645,8 +2675,7 @@ const deserializeAws_json1_1DescribeFeatureTransformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2656,10 +2685,12 @@ const deserializeAws_json1_1DescribeFeatureTransformationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2691,8 +2722,7 @@ const deserializeAws_json1_1DescribeFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2702,10 +2732,12 @@ const deserializeAws_json1_1DescribeFilterCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2737,8 +2769,7 @@ const deserializeAws_json1_1DescribeRecipeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2748,10 +2779,12 @@ const deserializeAws_json1_1DescribeRecipeCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2783,8 +2816,7 @@ const deserializeAws_json1_1DescribeRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2794,10 +2826,12 @@ const deserializeAws_json1_1DescribeRecommenderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2829,8 +2863,7 @@ const deserializeAws_json1_1DescribeSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2840,10 +2873,12 @@ const deserializeAws_json1_1DescribeSchemaCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2875,8 +2910,7 @@ const deserializeAws_json1_1DescribeSolutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2886,10 +2920,12 @@ const deserializeAws_json1_1DescribeSolutionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2921,8 +2957,7 @@ const deserializeAws_json1_1DescribeSolutionVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2932,10 +2967,12 @@ const deserializeAws_json1_1DescribeSolutionVersionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2967,8 +3004,7 @@ const deserializeAws_json1_1GetSolutionMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -2981,10 +3017,12 @@ const deserializeAws_json1_1GetSolutionMetricsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3016,8 +3054,7 @@ const deserializeAws_json1_1ListBatchInferenceJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3027,10 +3064,12 @@ const deserializeAws_json1_1ListBatchInferenceJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3062,8 +3101,7 @@ const deserializeAws_json1_1ListBatchSegmentJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3073,10 +3111,12 @@ const deserializeAws_json1_1ListBatchSegmentJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3108,8 +3148,7 @@ const deserializeAws_json1_1ListCampaignsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3119,10 +3158,12 @@ const deserializeAws_json1_1ListCampaignsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3154,8 +3195,7 @@ const deserializeAws_json1_1ListDatasetExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3165,10 +3205,12 @@ const deserializeAws_json1_1ListDatasetExportJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3200,18 +3242,19 @@ const deserializeAws_json1_1ListDatasetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.personalize#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3243,8 +3286,7 @@ const deserializeAws_json1_1ListDatasetImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3254,10 +3296,12 @@ const deserializeAws_json1_1ListDatasetImportJobsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3289,8 +3333,7 @@ const deserializeAws_json1_1ListDatasetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3300,10 +3343,12 @@ const deserializeAws_json1_1ListDatasetsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3335,8 +3380,7 @@ const deserializeAws_json1_1ListEventTrackersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3346,10 +3390,12 @@ const deserializeAws_json1_1ListEventTrackersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3381,8 +3427,7 @@ const deserializeAws_json1_1ListFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3392,10 +3437,12 @@ const deserializeAws_json1_1ListFiltersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3427,8 +3474,7 @@ const deserializeAws_json1_1ListRecipesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3438,10 +3484,12 @@ const deserializeAws_json1_1ListRecipesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3473,8 +3521,7 @@ const deserializeAws_json1_1ListRecommendersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3484,10 +3531,12 @@ const deserializeAws_json1_1ListRecommendersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3519,18 +3568,19 @@ const deserializeAws_json1_1ListSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.personalize#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3562,8 +3612,7 @@ const deserializeAws_json1_1ListSolutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3573,10 +3622,12 @@ const deserializeAws_json1_1ListSolutionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3608,8 +3659,7 @@ const deserializeAws_json1_1ListSolutionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3622,10 +3672,12 @@ const deserializeAws_json1_1ListSolutionVersionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3657,8 +3709,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3671,10 +3722,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3706,8 +3759,7 @@ const deserializeAws_json1_1StartRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3720,10 +3772,12 @@ const deserializeAws_json1_1StartRecommenderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3755,8 +3809,7 @@ const deserializeAws_json1_1StopRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3769,10 +3822,12 @@ const deserializeAws_json1_1StopRecommenderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3801,8 +3856,7 @@ const deserializeAws_json1_1StopSolutionVersionCreationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3815,10 +3869,12 @@ const deserializeAws_json1_1StopSolutionVersionCreationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3850,8 +3906,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3870,10 +3925,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3905,8 +3962,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3922,10 +3978,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagKeysExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3957,8 +4015,7 @@ const deserializeAws_json1_1UpdateCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -3971,10 +4028,12 @@ const deserializeAws_json1_1UpdateCampaignCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4006,8 +4065,7 @@ const deserializeAws_json1_1UpdateRecommenderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInputException": case "com.amazonaws.personalize#InvalidInputException": @@ -4020,10 +4078,12 @@ const deserializeAws_json1_1UpdateRecommenderCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7071,7 +7131,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7097,6 +7157,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pi/src/protocols/Aws_json1_1.ts b/clients/client-pi/src/protocols/Aws_json1_1.ts index fb1209e654436..1b87402a858c8 100644 --- a/clients/client-pi/src/protocols/Aws_json1_1.ts +++ b/clients/client-pi/src/protocols/Aws_json1_1.ts @@ -172,8 +172,7 @@ const deserializeAws_json1_1DescribeDimensionKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -186,10 +185,12 @@ const deserializeAws_json1_1DescribeDimensionKeysCommandError = async ( throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -221,8 +222,7 @@ const deserializeAws_json1_1GetDimensionKeyDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -235,10 +235,12 @@ const deserializeAws_json1_1GetDimensionKeyDetailsCommandError = async ( throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -270,8 +272,7 @@ const deserializeAws_json1_1GetResourceMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -284,10 +285,12 @@ const deserializeAws_json1_1GetResourceMetadataCommandError = async ( throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -319,8 +322,7 @@ const deserializeAws_json1_1GetResourceMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -333,10 +335,12 @@ const deserializeAws_json1_1GetResourceMetricsCommandError = async ( throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -368,8 +372,7 @@ const deserializeAws_json1_1ListAvailableResourceDimensionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -382,10 +385,12 @@ const deserializeAws_json1_1ListAvailableResourceDimensionsCommandError = async throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -417,8 +422,7 @@ const deserializeAws_json1_1ListAvailableResourceMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.pi#InternalServiceError": @@ -431,10 +435,12 @@ const deserializeAws_json1_1ListAvailableResourceMetricsCommandError = async ( throw await deserializeAws_json1_1NotAuthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1141,7 +1147,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1167,6 +1173,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pinpoint-email/src/protocols/Aws_restJson1.ts b/clients/client-pinpoint-email/src/protocols/Aws_restJson1.ts index 6aa0b0c4eeeb6..fd840e500e407 100644 --- a/clients/client-pinpoint-email/src/protocols/Aws_restJson1.ts +++ b/clients/client-pinpoint-email/src/protocols/Aws_restJson1.ts @@ -1551,8 +1551,7 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointemail#AlreadyExistsException": @@ -1574,10 +1573,12 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1606,8 +1607,7 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointemail#AlreadyExistsException": @@ -1626,10 +1626,12 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1658,8 +1660,7 @@ const deserializeAws_restJson1CreateDedicatedIpPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointemail#AlreadyExistsException": @@ -1678,10 +1679,12 @@ const deserializeAws_restJson1CreateDedicatedIpPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1718,8 +1721,7 @@ const deserializeAws_restJson1CreateDeliverabilityTestReportCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSuspendedException": case "com.amazonaws.pinpointemail#AccountSuspendedException": @@ -1750,10 +1752,12 @@ const deserializeAws_restJson1CreateDeliverabilityTestReportCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1794,8 +1798,7 @@ const deserializeAws_restJson1CreateEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -1811,10 +1814,12 @@ const deserializeAws_restJson1CreateEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1843,8 +1848,7 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -1860,10 +1864,12 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1892,8 +1898,7 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -1906,10 +1911,12 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1938,8 +1945,7 @@ const deserializeAws_restJson1DeleteDedicatedIpPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -1955,10 +1961,12 @@ const deserializeAws_restJson1DeleteDedicatedIpPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1987,8 +1995,7 @@ const deserializeAws_restJson1DeleteEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2004,10 +2011,12 @@ const deserializeAws_restJson1DeleteEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2056,8 +2065,7 @@ const deserializeAws_restJson1GetAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2067,10 +2075,12 @@ const deserializeAws_restJson1GetAccountCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2103,8 +2113,7 @@ const deserializeAws_restJson1GetBlacklistReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2117,10 +2126,12 @@ const deserializeAws_restJson1GetBlacklistReportsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2173,8 +2184,7 @@ const deserializeAws_restJson1GetConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2187,10 +2197,12 @@ const deserializeAws_restJson1GetConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2223,8 +2235,7 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2237,10 +2248,12 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,8 +2286,7 @@ const deserializeAws_restJson1GetDedicatedIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2287,10 +2299,12 @@ const deserializeAws_restJson1GetDedicatedIpCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2327,8 +2341,7 @@ const deserializeAws_restJson1GetDedicatedIpsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2341,10 +2354,12 @@ const deserializeAws_restJson1GetDedicatedIpsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2401,8 +2416,7 @@ const deserializeAws_restJson1GetDeliverabilityDashboardOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2415,10 +2429,12 @@ const deserializeAws_restJson1GetDeliverabilityDashboardOptionsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2470,8 +2486,7 @@ const deserializeAws_restJson1GetDeliverabilityTestReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2484,10 +2499,12 @@ const deserializeAws_restJson1GetDeliverabilityTestReportCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2523,8 +2540,7 @@ const deserializeAws_restJson1GetDomainDeliverabilityCampaignCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2537,10 +2553,12 @@ const deserializeAws_restJson1GetDomainDeliverabilityCampaignCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2577,8 +2595,7 @@ const deserializeAws_restJson1GetDomainStatisticsReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2591,10 +2608,12 @@ const deserializeAws_restJson1GetDomainStatisticsReportCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2647,8 +2666,7 @@ const deserializeAws_restJson1GetEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2661,10 +2679,12 @@ const deserializeAws_restJson1GetEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2701,8 +2721,7 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2712,10 +2731,12 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2752,8 +2773,7 @@ const deserializeAws_restJson1ListDedicatedIpPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2763,10 +2783,12 @@ const deserializeAws_restJson1ListDedicatedIpPoolsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2806,8 +2828,7 @@ const deserializeAws_restJson1ListDeliverabilityTestReportsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2820,10 +2841,12 @@ const deserializeAws_restJson1ListDeliverabilityTestReportsCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2863,8 +2886,7 @@ const deserializeAws_restJson1ListDomainDeliverabilityCampaignsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2877,10 +2899,12 @@ const deserializeAws_restJson1ListDomainDeliverabilityCampaignsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2917,8 +2941,7 @@ const deserializeAws_restJson1ListEmailIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2928,10 +2951,12 @@ const deserializeAws_restJson1ListEmailIdentitiesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2964,8 +2989,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -2978,10 +3002,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3010,8 +3036,7 @@ const deserializeAws_restJson1PutAccountDedicatedIpWarmupAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3021,10 +3046,12 @@ const deserializeAws_restJson1PutAccountDedicatedIpWarmupAttributesCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3053,8 +3080,7 @@ const deserializeAws_restJson1PutAccountSendingAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3064,10 +3090,12 @@ const deserializeAws_restJson1PutAccountSendingAttributesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3096,8 +3124,7 @@ const deserializeAws_restJson1PutConfigurationSetDeliveryOptionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3110,10 +3137,12 @@ const deserializeAws_restJson1PutConfigurationSetDeliveryOptionsCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3142,8 +3171,7 @@ const deserializeAws_restJson1PutConfigurationSetReputationOptionsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3156,10 +3184,12 @@ const deserializeAws_restJson1PutConfigurationSetReputationOptionsCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3188,8 +3218,7 @@ const deserializeAws_restJson1PutConfigurationSetSendingOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3202,10 +3231,12 @@ const deserializeAws_restJson1PutConfigurationSetSendingOptionsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3234,8 +3265,7 @@ const deserializeAws_restJson1PutConfigurationSetTrackingOptionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3248,10 +3278,12 @@ const deserializeAws_restJson1PutConfigurationSetTrackingOptionsCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3280,8 +3312,7 @@ const deserializeAws_restJson1PutDedicatedIpInPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3294,10 +3325,12 @@ const deserializeAws_restJson1PutDedicatedIpInPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3326,8 +3359,7 @@ const deserializeAws_restJson1PutDedicatedIpWarmupAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3340,10 +3372,12 @@ const deserializeAws_restJson1PutDedicatedIpWarmupAttributesCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3372,8 +3406,7 @@ const deserializeAws_restJson1PutDeliverabilityDashboardOptionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointemail#AlreadyExistsException": @@ -3392,10 +3425,12 @@ const deserializeAws_restJson1PutDeliverabilityDashboardOptionCommandError = asy throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3424,8 +3459,7 @@ const deserializeAws_restJson1PutEmailIdentityDkimAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3438,10 +3472,12 @@ const deserializeAws_restJson1PutEmailIdentityDkimAttributesCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3470,8 +3506,7 @@ const deserializeAws_restJson1PutEmailIdentityFeedbackAttributesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3484,10 +3519,12 @@ const deserializeAws_restJson1PutEmailIdentityFeedbackAttributesCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3516,8 +3553,7 @@ const deserializeAws_restJson1PutEmailIdentityMailFromAttributesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3530,10 +3566,12 @@ const deserializeAws_restJson1PutEmailIdentityMailFromAttributesCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3566,8 +3604,7 @@ const deserializeAws_restJson1SendEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSuspendedException": case "com.amazonaws.pinpointemail#AccountSuspendedException": @@ -3595,10 +3632,12 @@ const deserializeAws_restJson1SendEmailCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3627,8 +3666,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3644,10 +3682,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3676,8 +3716,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3693,10 +3732,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3725,8 +3766,7 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointemail#BadRequestException": @@ -3739,10 +3779,12 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4815,7 +4857,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4841,6 +4883,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pinpoint-sms-voice-v2/src/protocols/Aws_json1_0.ts b/clients/client-pinpoint-sms-voice-v2/src/protocols/Aws_json1_0.ts index 4317ad5e35e00..3fd7ac0e9fa4e 100644 --- a/clients/client-pinpoint-sms-voice-v2/src/protocols/Aws_json1_0.ts +++ b/clients/client-pinpoint-sms-voice-v2/src/protocols/Aws_json1_0.ts @@ -843,8 +843,7 @@ const deserializeAws_json1_0AssociateOriginationIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -869,10 +868,12 @@ const deserializeAws_json1_0AssociateOriginationIdentityCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -904,8 +905,7 @@ const deserializeAws_json1_0CreateConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -927,10 +927,12 @@ const deserializeAws_json1_0CreateConfigurationSetCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -962,8 +964,7 @@ const deserializeAws_json1_0CreateEventDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -988,10 +989,12 @@ const deserializeAws_json1_0CreateEventDestinationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1023,8 +1026,7 @@ const deserializeAws_json1_0CreateOptOutListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1046,10 +1048,12 @@ const deserializeAws_json1_0CreateOptOutListCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1081,8 +1085,7 @@ const deserializeAws_json1_0CreatePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1107,10 +1110,12 @@ const deserializeAws_json1_0CreatePoolCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1142,8 +1147,7 @@ const deserializeAws_json1_0DeleteConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1162,10 +1166,12 @@ const deserializeAws_json1_0DeleteConfigurationSetCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1197,8 +1203,7 @@ const deserializeAws_json1_0DeleteDefaultMessageTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1217,10 +1222,12 @@ const deserializeAws_json1_0DeleteDefaultMessageTypeCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1252,8 +1259,7 @@ const deserializeAws_json1_0DeleteDefaultSenderIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1272,10 +1278,12 @@ const deserializeAws_json1_0DeleteDefaultSenderIdCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1307,8 +1315,7 @@ const deserializeAws_json1_0DeleteEventDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1327,10 +1334,12 @@ const deserializeAws_json1_0DeleteEventDestinationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1362,8 +1371,7 @@ const deserializeAws_json1_0DeleteKeywordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1385,10 +1393,12 @@ const deserializeAws_json1_0DeleteKeywordCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1420,8 +1430,7 @@ const deserializeAws_json1_0DeleteOptedOutNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1443,10 +1452,12 @@ const deserializeAws_json1_0DeleteOptedOutNumberCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1489,7 @@ const deserializeAws_json1_0DeleteOptOutListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1501,10 +1511,12 @@ const deserializeAws_json1_0DeleteOptOutListCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1536,8 +1548,7 @@ const deserializeAws_json1_0DeletePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1559,10 +1570,12 @@ const deserializeAws_json1_0DeletePoolCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1594,8 +1607,7 @@ const deserializeAws_json1_0DeleteTextMessageSpendLimitOverrideCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1611,10 +1623,12 @@ const deserializeAws_json1_0DeleteTextMessageSpendLimitOverrideCommandError = as throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1646,8 +1660,7 @@ const deserializeAws_json1_0DeleteVoiceMessageSpendLimitOverrideCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1663,10 +1676,12 @@ const deserializeAws_json1_0DeleteVoiceMessageSpendLimitOverrideCommandError = a throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1698,8 +1713,7 @@ const deserializeAws_json1_0DescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1715,10 +1729,12 @@ const deserializeAws_json1_0DescribeAccountAttributesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1750,8 +1766,7 @@ const deserializeAws_json1_0DescribeAccountLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1767,10 +1782,12 @@ const deserializeAws_json1_0DescribeAccountLimitsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1802,8 +1819,7 @@ const deserializeAws_json1_0DescribeConfigurationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1822,10 +1838,12 @@ const deserializeAws_json1_0DescribeConfigurationSetsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1857,8 +1875,7 @@ const deserializeAws_json1_0DescribeKeywordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1877,10 +1894,12 @@ const deserializeAws_json1_0DescribeKeywordsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1912,8 +1931,7 @@ const deserializeAws_json1_0DescribeOptedOutNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1932,10 +1950,12 @@ const deserializeAws_json1_0DescribeOptedOutNumbersCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1967,8 +1987,7 @@ const deserializeAws_json1_0DescribeOptOutListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -1987,10 +2006,12 @@ const deserializeAws_json1_0DescribeOptOutListsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2022,8 +2043,7 @@ const deserializeAws_json1_0DescribePhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2042,10 +2062,12 @@ const deserializeAws_json1_0DescribePhoneNumbersCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,8 +2099,7 @@ const deserializeAws_json1_0DescribePoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2097,10 +2118,12 @@ const deserializeAws_json1_0DescribePoolsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2132,8 +2155,7 @@ const deserializeAws_json1_0DescribeSenderIdsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2152,10 +2174,12 @@ const deserializeAws_json1_0DescribeSenderIdsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2187,8 +2211,7 @@ const deserializeAws_json1_0DescribeSpendLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2204,10 +2227,12 @@ const deserializeAws_json1_0DescribeSpendLimitsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2239,8 +2264,7 @@ const deserializeAws_json1_0DisassociateOriginationIdentityCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2262,10 +2286,12 @@ const deserializeAws_json1_0DisassociateOriginationIdentityCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2297,8 +2323,7 @@ const deserializeAws_json1_0ListPoolOriginationIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2317,10 +2342,12 @@ const deserializeAws_json1_0ListPoolOriginationIdentitiesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2352,8 +2379,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2372,10 +2398,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2407,8 +2435,7 @@ const deserializeAws_json1_0PutKeywordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2433,10 +2460,12 @@ const deserializeAws_json1_0PutKeywordCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2468,8 +2497,7 @@ const deserializeAws_json1_0PutOptedOutNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2488,10 +2516,12 @@ const deserializeAws_json1_0PutOptedOutNumberCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2523,8 +2553,7 @@ const deserializeAws_json1_0ReleasePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2546,10 +2575,12 @@ const deserializeAws_json1_0ReleasePhoneNumberCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2581,8 +2612,7 @@ const deserializeAws_json1_0RequestPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2607,10 +2637,12 @@ const deserializeAws_json1_0RequestPhoneNumberCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2642,8 +2674,7 @@ const deserializeAws_json1_0SendTextMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2668,10 +2699,12 @@ const deserializeAws_json1_0SendTextMessageCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2703,8 +2736,7 @@ const deserializeAws_json1_0SendVoiceMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2729,10 +2761,12 @@ const deserializeAws_json1_0SendVoiceMessageCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2764,8 +2798,7 @@ const deserializeAws_json1_0SetDefaultMessageTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2784,10 +2817,12 @@ const deserializeAws_json1_0SetDefaultMessageTypeCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2819,8 +2854,7 @@ const deserializeAws_json1_0SetDefaultSenderIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2839,10 +2873,12 @@ const deserializeAws_json1_0SetDefaultSenderIdCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2874,8 +2910,7 @@ const deserializeAws_json1_0SetTextMessageSpendLimitOverrideCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2891,10 +2926,12 @@ const deserializeAws_json1_0SetTextMessageSpendLimitOverrideCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2926,8 +2963,7 @@ const deserializeAws_json1_0SetVoiceMessageSpendLimitOverrideCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -2943,10 +2979,12 @@ const deserializeAws_json1_0SetVoiceMessageSpendLimitOverrideCommandError = asyn throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2978,8 +3016,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -3001,10 +3038,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3036,8 +3075,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -3056,10 +3094,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3091,8 +3131,7 @@ const deserializeAws_json1_0UpdateEventDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -3114,10 +3153,12 @@ const deserializeAws_json1_0UpdateEventDestinationCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3149,8 +3190,7 @@ const deserializeAws_json1_0UpdatePhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -3172,10 +3212,12 @@ const deserializeAws_json1_0UpdatePhoneNumberCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3207,8 +3249,7 @@ const deserializeAws_json1_0UpdatePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.pinpointsmsvoicev2#AccessDeniedException": @@ -3230,10 +3271,12 @@ const deserializeAws_json1_0UpdatePoolCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5415,7 +5458,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5441,6 +5484,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pinpoint-sms-voice/src/protocols/Aws_restJson1.ts b/clients/client-pinpoint-sms-voice/src/protocols/Aws_restJson1.ts index fcd1f6873395a..d03ff2f829c23 100644 --- a/clients/client-pinpoint-sms-voice/src/protocols/Aws_restJson1.ts +++ b/clients/client-pinpoint-sms-voice/src/protocols/Aws_restJson1.ts @@ -356,8 +356,7 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointsmsvoice#AlreadyExistsException": @@ -376,10 +375,12 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -408,8 +409,7 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.pinpointsmsvoice#AlreadyExistsException": @@ -431,10 +431,12 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -463,8 +465,7 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -480,10 +481,12 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -512,8 +515,7 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -529,10 +531,12 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -565,8 +569,7 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -582,10 +585,12 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -622,8 +627,7 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -636,10 +640,12 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -672,8 +678,7 @@ const deserializeAws_restJson1SendVoiceMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -686,10 +691,12 @@ const deserializeAws_restJson1SendVoiceMessageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -718,8 +725,7 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpointsmsvoice#BadRequestException": @@ -735,10 +741,12 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1074,7 +1082,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1100,6 +1108,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pinpoint/src/protocols/Aws_restJson1.ts b/clients/client-pinpoint/src/protocols/Aws_restJson1.ts index 8d3026d275c00..097151ad661ae 100644 --- a/clients/client-pinpoint/src/protocols/Aws_restJson1.ts +++ b/clients/client-pinpoint/src/protocols/Aws_restJson1.ts @@ -4844,8 +4844,7 @@ const deserializeAws_restJson1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -4870,10 +4869,12 @@ const deserializeAws_restJson1CreateAppCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4904,8 +4905,7 @@ const deserializeAws_restJson1CreateCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -4930,10 +4930,12 @@ const deserializeAws_restJson1CreateCampaignCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4964,8 +4966,7 @@ const deserializeAws_restJson1CreateEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -4984,10 +4985,12 @@ const deserializeAws_restJson1CreateEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5018,8 +5021,7 @@ const deserializeAws_restJson1CreateExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5044,10 +5046,12 @@ const deserializeAws_restJson1CreateExportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5078,8 +5082,7 @@ const deserializeAws_restJson1CreateImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5104,10 +5107,12 @@ const deserializeAws_restJson1CreateImportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5138,8 +5143,7 @@ const deserializeAws_restJson1CreateInAppTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5158,10 +5162,12 @@ const deserializeAws_restJson1CreateInAppTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5192,8 +5198,7 @@ const deserializeAws_restJson1CreateJourneyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5218,10 +5223,12 @@ const deserializeAws_restJson1CreateJourneyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5252,8 +5259,7 @@ const deserializeAws_restJson1CreatePushTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5272,10 +5278,12 @@ const deserializeAws_restJson1CreatePushTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5306,8 +5314,7 @@ const deserializeAws_restJson1CreateRecommenderConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5332,10 +5339,12 @@ const deserializeAws_restJson1CreateRecommenderConfigurationCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5366,8 +5375,7 @@ const deserializeAws_restJson1CreateSegmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5392,10 +5400,12 @@ const deserializeAws_restJson1CreateSegmentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5426,8 +5436,7 @@ const deserializeAws_restJson1CreateSmsTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5446,10 +5455,12 @@ const deserializeAws_restJson1CreateSmsTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5480,8 +5491,7 @@ const deserializeAws_restJson1CreateVoiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5500,10 +5510,12 @@ const deserializeAws_restJson1CreateVoiceTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5534,8 +5546,7 @@ const deserializeAws_restJson1DeleteAdmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5560,10 +5571,12 @@ const deserializeAws_restJson1DeleteAdmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5594,8 +5607,7 @@ const deserializeAws_restJson1DeleteApnsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5620,10 +5632,12 @@ const deserializeAws_restJson1DeleteApnsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5654,8 +5668,7 @@ const deserializeAws_restJson1DeleteApnsSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5680,10 +5693,12 @@ const deserializeAws_restJson1DeleteApnsSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5714,8 +5729,7 @@ const deserializeAws_restJson1DeleteApnsVoipChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5740,10 +5754,12 @@ const deserializeAws_restJson1DeleteApnsVoipChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5774,8 +5790,7 @@ const deserializeAws_restJson1DeleteApnsVoipSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5800,10 +5815,12 @@ const deserializeAws_restJson1DeleteApnsVoipSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5834,8 +5851,7 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5860,10 +5876,12 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5894,8 +5912,7 @@ const deserializeAws_restJson1DeleteBaiduChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5920,10 +5937,12 @@ const deserializeAws_restJson1DeleteBaiduChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5954,8 +5973,7 @@ const deserializeAws_restJson1DeleteCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -5980,10 +5998,12 @@ const deserializeAws_restJson1DeleteCampaignCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6014,8 +6034,7 @@ const deserializeAws_restJson1DeleteEmailChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6040,10 +6059,12 @@ const deserializeAws_restJson1DeleteEmailChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6074,8 +6095,7 @@ const deserializeAws_restJson1DeleteEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6100,10 +6120,12 @@ const deserializeAws_restJson1DeleteEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6134,8 +6156,7 @@ const deserializeAws_restJson1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6160,10 +6181,12 @@ const deserializeAws_restJson1DeleteEndpointCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6194,8 +6217,7 @@ const deserializeAws_restJson1DeleteEventStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6220,10 +6242,12 @@ const deserializeAws_restJson1DeleteEventStreamCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6254,8 +6278,7 @@ const deserializeAws_restJson1DeleteGcmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6280,10 +6303,12 @@ const deserializeAws_restJson1DeleteGcmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6314,8 +6339,7 @@ const deserializeAws_restJson1DeleteInAppTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6340,10 +6364,12 @@ const deserializeAws_restJson1DeleteInAppTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6374,8 +6400,7 @@ const deserializeAws_restJson1DeleteJourneyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6400,10 +6425,12 @@ const deserializeAws_restJson1DeleteJourneyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6434,8 +6461,7 @@ const deserializeAws_restJson1DeletePushTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6460,10 +6486,12 @@ const deserializeAws_restJson1DeletePushTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6494,8 +6522,7 @@ const deserializeAws_restJson1DeleteRecommenderConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6520,10 +6547,12 @@ const deserializeAws_restJson1DeleteRecommenderConfigurationCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6554,8 +6583,7 @@ const deserializeAws_restJson1DeleteSegmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6580,10 +6608,12 @@ const deserializeAws_restJson1DeleteSegmentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6614,8 +6644,7 @@ const deserializeAws_restJson1DeleteSmsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6640,10 +6669,12 @@ const deserializeAws_restJson1DeleteSmsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6674,8 +6705,7 @@ const deserializeAws_restJson1DeleteSmsTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6700,10 +6730,12 @@ const deserializeAws_restJson1DeleteSmsTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6734,8 +6766,7 @@ const deserializeAws_restJson1DeleteUserEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6760,10 +6791,12 @@ const deserializeAws_restJson1DeleteUserEndpointsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6794,8 +6827,7 @@ const deserializeAws_restJson1DeleteVoiceChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6820,10 +6852,12 @@ const deserializeAws_restJson1DeleteVoiceChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6854,8 +6888,7 @@ const deserializeAws_restJson1DeleteVoiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6880,10 +6913,12 @@ const deserializeAws_restJson1DeleteVoiceTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6914,8 +6949,7 @@ const deserializeAws_restJson1GetAdmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -6940,10 +6974,12 @@ const deserializeAws_restJson1GetAdmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6974,8 +7010,7 @@ const deserializeAws_restJson1GetApnsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7000,10 +7035,12 @@ const deserializeAws_restJson1GetApnsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7034,8 +7071,7 @@ const deserializeAws_restJson1GetApnsSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7060,10 +7096,12 @@ const deserializeAws_restJson1GetApnsSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7094,8 +7132,7 @@ const deserializeAws_restJson1GetApnsVoipChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7120,10 +7157,12 @@ const deserializeAws_restJson1GetApnsVoipChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7154,8 +7193,7 @@ const deserializeAws_restJson1GetApnsVoipSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7180,10 +7218,12 @@ const deserializeAws_restJson1GetApnsVoipSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7214,8 +7254,7 @@ const deserializeAws_restJson1GetAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7240,10 +7279,12 @@ const deserializeAws_restJson1GetAppCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7274,8 +7315,7 @@ const deserializeAws_restJson1GetApplicationDateRangeKpiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7300,10 +7340,12 @@ const deserializeAws_restJson1GetApplicationDateRangeKpiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7334,8 +7376,7 @@ const deserializeAws_restJson1GetApplicationSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7360,10 +7401,12 @@ const deserializeAws_restJson1GetApplicationSettingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7394,8 +7437,7 @@ const deserializeAws_restJson1GetAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7420,10 +7462,12 @@ const deserializeAws_restJson1GetAppsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7454,8 +7498,7 @@ const deserializeAws_restJson1GetBaiduChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7480,10 +7523,12 @@ const deserializeAws_restJson1GetBaiduChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7514,8 +7559,7 @@ const deserializeAws_restJson1GetCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7540,10 +7584,12 @@ const deserializeAws_restJson1GetCampaignCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7574,8 +7620,7 @@ const deserializeAws_restJson1GetCampaignActivitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7600,10 +7645,12 @@ const deserializeAws_restJson1GetCampaignActivitiesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7634,8 +7681,7 @@ const deserializeAws_restJson1GetCampaignDateRangeKpiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7660,10 +7706,12 @@ const deserializeAws_restJson1GetCampaignDateRangeKpiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7694,8 +7742,7 @@ const deserializeAws_restJson1GetCampaignsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7720,10 +7767,12 @@ const deserializeAws_restJson1GetCampaignsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7754,8 +7803,7 @@ const deserializeAws_restJson1GetCampaignVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7780,10 +7828,12 @@ const deserializeAws_restJson1GetCampaignVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7814,8 +7864,7 @@ const deserializeAws_restJson1GetCampaignVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7840,10 +7889,12 @@ const deserializeAws_restJson1GetCampaignVersionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7874,8 +7925,7 @@ const deserializeAws_restJson1GetChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7900,10 +7950,12 @@ const deserializeAws_restJson1GetChannelsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7934,8 +7986,7 @@ const deserializeAws_restJson1GetEmailChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -7960,10 +8011,12 @@ const deserializeAws_restJson1GetEmailChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7994,8 +8047,7 @@ const deserializeAws_restJson1GetEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8020,10 +8072,12 @@ const deserializeAws_restJson1GetEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8054,8 +8108,7 @@ const deserializeAws_restJson1GetEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8080,10 +8133,12 @@ const deserializeAws_restJson1GetEndpointCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8114,8 +8169,7 @@ const deserializeAws_restJson1GetEventStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8140,10 +8194,12 @@ const deserializeAws_restJson1GetEventStreamCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8174,8 +8230,7 @@ const deserializeAws_restJson1GetExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8200,10 +8255,12 @@ const deserializeAws_restJson1GetExportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8234,8 +8291,7 @@ const deserializeAws_restJson1GetExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8260,10 +8316,12 @@ const deserializeAws_restJson1GetExportJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8294,8 +8352,7 @@ const deserializeAws_restJson1GetGcmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8320,10 +8377,12 @@ const deserializeAws_restJson1GetGcmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8354,8 +8413,7 @@ const deserializeAws_restJson1GetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8380,10 +8438,12 @@ const deserializeAws_restJson1GetImportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8414,8 +8474,7 @@ const deserializeAws_restJson1GetImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8440,10 +8499,12 @@ const deserializeAws_restJson1GetImportJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8474,8 +8535,7 @@ const deserializeAws_restJson1GetInAppMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8500,10 +8560,12 @@ const deserializeAws_restJson1GetInAppMessagesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8534,8 +8596,7 @@ const deserializeAws_restJson1GetInAppTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8560,10 +8621,12 @@ const deserializeAws_restJson1GetInAppTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8594,8 +8657,7 @@ const deserializeAws_restJson1GetJourneyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8620,10 +8682,12 @@ const deserializeAws_restJson1GetJourneyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8654,8 +8718,7 @@ const deserializeAws_restJson1GetJourneyDateRangeKpiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8680,10 +8743,12 @@ const deserializeAws_restJson1GetJourneyDateRangeKpiCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8717,8 +8782,7 @@ const deserializeAws_restJson1GetJourneyExecutionActivityMetricsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8743,10 +8807,12 @@ const deserializeAws_restJson1GetJourneyExecutionActivityMetricsCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8777,8 +8843,7 @@ const deserializeAws_restJson1GetJourneyExecutionMetricsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8803,10 +8868,12 @@ const deserializeAws_restJson1GetJourneyExecutionMetricsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8837,8 +8904,7 @@ const deserializeAws_restJson1GetPushTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8863,10 +8929,12 @@ const deserializeAws_restJson1GetPushTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8897,8 +8965,7 @@ const deserializeAws_restJson1GetRecommenderConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8923,10 +8990,12 @@ const deserializeAws_restJson1GetRecommenderConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8960,8 +9029,7 @@ const deserializeAws_restJson1GetRecommenderConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -8986,10 +9054,12 @@ const deserializeAws_restJson1GetRecommenderConfigurationsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9020,8 +9090,7 @@ const deserializeAws_restJson1GetSegmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9046,10 +9115,12 @@ const deserializeAws_restJson1GetSegmentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9080,8 +9151,7 @@ const deserializeAws_restJson1GetSegmentExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9106,10 +9176,12 @@ const deserializeAws_restJson1GetSegmentExportJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9140,8 +9212,7 @@ const deserializeAws_restJson1GetSegmentImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9166,10 +9237,12 @@ const deserializeAws_restJson1GetSegmentImportJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9200,8 +9273,7 @@ const deserializeAws_restJson1GetSegmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9226,10 +9298,12 @@ const deserializeAws_restJson1GetSegmentsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9260,8 +9334,7 @@ const deserializeAws_restJson1GetSegmentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9286,10 +9359,12 @@ const deserializeAws_restJson1GetSegmentVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9320,8 +9395,7 @@ const deserializeAws_restJson1GetSegmentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9346,10 +9420,12 @@ const deserializeAws_restJson1GetSegmentVersionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9380,8 +9456,7 @@ const deserializeAws_restJson1GetSmsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9406,10 +9481,12 @@ const deserializeAws_restJson1GetSmsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9440,8 +9517,7 @@ const deserializeAws_restJson1GetSmsTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9466,10 +9542,12 @@ const deserializeAws_restJson1GetSmsTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9500,8 +9578,7 @@ const deserializeAws_restJson1GetUserEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9526,10 +9603,12 @@ const deserializeAws_restJson1GetUserEndpointsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9560,8 +9639,7 @@ const deserializeAws_restJson1GetVoiceChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9586,10 +9664,12 @@ const deserializeAws_restJson1GetVoiceChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9620,8 +9700,7 @@ const deserializeAws_restJson1GetVoiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9646,10 +9725,12 @@ const deserializeAws_restJson1GetVoiceTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9680,8 +9761,7 @@ const deserializeAws_restJson1ListJourneysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9706,10 +9786,12 @@ const deserializeAws_restJson1ListJourneysCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9740,15 +9822,16 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9779,8 +9862,7 @@ const deserializeAws_restJson1ListTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9799,10 +9881,12 @@ const deserializeAws_restJson1ListTemplatesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9833,8 +9917,7 @@ const deserializeAws_restJson1ListTemplateVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9859,10 +9942,12 @@ const deserializeAws_restJson1ListTemplateVersionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9893,8 +9978,7 @@ const deserializeAws_restJson1PhoneNumberValidateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9919,10 +10003,12 @@ const deserializeAws_restJson1PhoneNumberValidateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9953,8 +10039,7 @@ const deserializeAws_restJson1PutEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -9979,10 +10064,12 @@ const deserializeAws_restJson1PutEventsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10013,8 +10100,7 @@ const deserializeAws_restJson1PutEventStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10039,10 +10125,12 @@ const deserializeAws_restJson1PutEventStreamCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10073,8 +10161,7 @@ const deserializeAws_restJson1RemoveAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10099,10 +10186,12 @@ const deserializeAws_restJson1RemoveAttributesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10133,8 +10222,7 @@ const deserializeAws_restJson1SendMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10159,10 +10247,12 @@ const deserializeAws_restJson1SendMessagesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10193,8 +10283,7 @@ const deserializeAws_restJson1SendOTPMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10219,10 +10308,12 @@ const deserializeAws_restJson1SendOTPMessageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10253,8 +10344,7 @@ const deserializeAws_restJson1SendUsersMessagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10279,10 +10369,12 @@ const deserializeAws_restJson1SendUsersMessagesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10311,15 +10403,16 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10348,15 +10441,16 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10387,8 +10481,7 @@ const deserializeAws_restJson1UpdateAdmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10413,10 +10506,12 @@ const deserializeAws_restJson1UpdateAdmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10447,8 +10542,7 @@ const deserializeAws_restJson1UpdateApnsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10473,10 +10567,12 @@ const deserializeAws_restJson1UpdateApnsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10507,8 +10603,7 @@ const deserializeAws_restJson1UpdateApnsSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10533,10 +10628,12 @@ const deserializeAws_restJson1UpdateApnsSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10567,8 +10664,7 @@ const deserializeAws_restJson1UpdateApnsVoipChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10593,10 +10689,12 @@ const deserializeAws_restJson1UpdateApnsVoipChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10627,8 +10725,7 @@ const deserializeAws_restJson1UpdateApnsVoipSandboxChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10653,10 +10750,12 @@ const deserializeAws_restJson1UpdateApnsVoipSandboxChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10687,8 +10786,7 @@ const deserializeAws_restJson1UpdateApplicationSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10713,10 +10811,12 @@ const deserializeAws_restJson1UpdateApplicationSettingsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10747,8 +10847,7 @@ const deserializeAws_restJson1UpdateBaiduChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10773,10 +10872,12 @@ const deserializeAws_restJson1UpdateBaiduChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10807,8 +10908,7 @@ const deserializeAws_restJson1UpdateCampaignCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10833,10 +10933,12 @@ const deserializeAws_restJson1UpdateCampaignCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10867,8 +10969,7 @@ const deserializeAws_restJson1UpdateEmailChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10893,10 +10994,12 @@ const deserializeAws_restJson1UpdateEmailChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10927,8 +11030,7 @@ const deserializeAws_restJson1UpdateEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -10953,10 +11055,12 @@ const deserializeAws_restJson1UpdateEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10987,8 +11091,7 @@ const deserializeAws_restJson1UpdateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11013,10 +11116,12 @@ const deserializeAws_restJson1UpdateEndpointCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11047,8 +11152,7 @@ const deserializeAws_restJson1UpdateEndpointsBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11073,10 +11177,12 @@ const deserializeAws_restJson1UpdateEndpointsBatchCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11107,8 +11213,7 @@ const deserializeAws_restJson1UpdateGcmChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11133,10 +11238,12 @@ const deserializeAws_restJson1UpdateGcmChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11167,8 +11274,7 @@ const deserializeAws_restJson1UpdateInAppTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11193,10 +11299,12 @@ const deserializeAws_restJson1UpdateInAppTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11227,8 +11335,7 @@ const deserializeAws_restJson1UpdateJourneyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11256,10 +11363,12 @@ const deserializeAws_restJson1UpdateJourneyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11290,8 +11399,7 @@ const deserializeAws_restJson1UpdateJourneyStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11316,10 +11424,12 @@ const deserializeAws_restJson1UpdateJourneyStateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11350,8 +11460,7 @@ const deserializeAws_restJson1UpdatePushTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11376,10 +11485,12 @@ const deserializeAws_restJson1UpdatePushTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11410,8 +11521,7 @@ const deserializeAws_restJson1UpdateRecommenderConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11436,10 +11546,12 @@ const deserializeAws_restJson1UpdateRecommenderConfigurationCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11470,8 +11582,7 @@ const deserializeAws_restJson1UpdateSegmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11496,10 +11607,12 @@ const deserializeAws_restJson1UpdateSegmentCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11530,8 +11643,7 @@ const deserializeAws_restJson1UpdateSmsChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11556,10 +11668,12 @@ const deserializeAws_restJson1UpdateSmsChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11590,8 +11704,7 @@ const deserializeAws_restJson1UpdateSmsTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11616,10 +11729,12 @@ const deserializeAws_restJson1UpdateSmsTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11650,8 +11765,7 @@ const deserializeAws_restJson1UpdateTemplateActiveVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11676,10 +11790,12 @@ const deserializeAws_restJson1UpdateTemplateActiveVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11710,8 +11826,7 @@ const deserializeAws_restJson1UpdateVoiceChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11736,10 +11851,12 @@ const deserializeAws_restJson1UpdateVoiceChannelCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11770,8 +11887,7 @@ const deserializeAws_restJson1UpdateVoiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11796,10 +11912,12 @@ const deserializeAws_restJson1UpdateVoiceTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11830,8 +11948,7 @@ const deserializeAws_restJson1VerifyOTPMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.pinpoint#BadRequestException": @@ -11856,10 +11973,12 @@ const deserializeAws_restJson1VerifyOTPMessageCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -16647,7 +16766,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -16673,6 +16792,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-polly/src/protocols/Aws_restJson1.ts b/clients/client-polly/src/protocols/Aws_restJson1.ts index 6a3b2b12391a4..2a592bd2a28cc 100644 --- a/clients/client-polly/src/protocols/Aws_restJson1.ts +++ b/clients/client-polly/src/protocols/Aws_restJson1.ts @@ -366,8 +366,7 @@ const deserializeAws_restJson1DeleteLexiconCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LexiconNotFoundException": case "com.amazonaws.polly#LexiconNotFoundException": @@ -377,10 +376,12 @@ const deserializeAws_restJson1DeleteLexiconCommandError = async ( throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -417,8 +418,7 @@ const deserializeAws_restJson1DescribeVoicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.polly#InvalidNextTokenException": @@ -428,10 +428,12 @@ const deserializeAws_restJson1DescribeVoicesCommandError = async ( throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -468,8 +470,7 @@ const deserializeAws_restJson1GetLexiconCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LexiconNotFoundException": case "com.amazonaws.polly#LexiconNotFoundException": @@ -479,10 +480,12 @@ const deserializeAws_restJson1GetLexiconCommandError = async ( throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -515,8 +518,7 @@ const deserializeAws_restJson1GetSpeechSynthesisTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTaskIdException": case "com.amazonaws.polly#InvalidTaskIdException": @@ -529,10 +531,12 @@ const deserializeAws_restJson1GetSpeechSynthesisTaskCommandError = async ( throw await deserializeAws_restJson1SynthesisTaskNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -569,8 +573,7 @@ const deserializeAws_restJson1ListLexiconsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.polly#InvalidNextTokenException": @@ -580,10 +583,12 @@ const deserializeAws_restJson1ListLexiconsCommandError = async ( throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -620,8 +625,7 @@ const deserializeAws_restJson1ListSpeechSynthesisTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.polly#InvalidNextTokenException": @@ -631,10 +635,12 @@ const deserializeAws_restJson1ListSpeechSynthesisTasksCommandError = async ( throw await deserializeAws_restJson1ServiceFailureExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -663,8 +669,7 @@ const deserializeAws_restJson1PutLexiconCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLexiconException": case "com.amazonaws.polly#InvalidLexiconException": @@ -689,10 +694,12 @@ const deserializeAws_restJson1PutLexiconCommandError = async ( throw await deserializeAws_restJson1UnsupportedPlsLanguageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -725,8 +732,7 @@ const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EngineNotSupportedException": case "com.amazonaws.polly#EngineNotSupportedException": @@ -766,10 +772,12 @@ const deserializeAws_restJson1StartSpeechSynthesisTaskCommandError = async ( throw await deserializeAws_restJson1TextLengthExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -808,8 +816,7 @@ const deserializeAws_restJson1SynthesizeSpeechCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EngineNotSupportedException": case "com.amazonaws.polly#EngineNotSupportedException": @@ -840,10 +847,12 @@ const deserializeAws_restJson1SynthesizeSpeechCommandError = async ( throw await deserializeAws_restJson1TextLengthExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1409,7 +1418,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1435,6 +1444,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-pricing/src/protocols/Aws_json1_1.ts b/clients/client-pricing/src/protocols/Aws_json1_1.ts index a06ca7133ed9c..40145f9417e11 100644 --- a/clients/client-pricing/src/protocols/Aws_json1_1.ts +++ b/clients/client-pricing/src/protocols/Aws_json1_1.ts @@ -98,8 +98,7 @@ const deserializeAws_json1_1DescribeServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredNextTokenException": case "com.amazonaws.pricing#ExpiredNextTokenException": @@ -118,10 +117,12 @@ const deserializeAws_json1_1DescribeServicesCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -153,8 +154,7 @@ const deserializeAws_json1_1GetAttributeValuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredNextTokenException": case "com.amazonaws.pricing#ExpiredNextTokenException": @@ -173,10 +173,12 @@ const deserializeAws_json1_1GetAttributeValuesCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -208,8 +210,7 @@ const deserializeAws_json1_1GetProductsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredNextTokenException": case "com.amazonaws.pricing#ExpiredNextTokenException": @@ -228,10 +229,12 @@ const deserializeAws_json1_1GetProductsCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -549,7 +552,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -575,6 +578,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-proton/src/protocols/Aws_json1_0.ts b/clients/client-proton/src/protocols/Aws_json1_0.ts index 1e2d818ea7958..9e6f83a76cce9 100644 --- a/clients/client-proton/src/protocols/Aws_json1_0.ts +++ b/clients/client-proton/src/protocols/Aws_json1_0.ts @@ -1446,8 +1446,7 @@ const deserializeAws_json1_0AcceptEnvironmentAccountConnectionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1469,10 +1468,12 @@ const deserializeAws_json1_0AcceptEnvironmentAccountConnectionCommandError = asy throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1504,8 +1505,7 @@ const deserializeAws_json1_0CancelComponentDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1527,10 +1527,12 @@ const deserializeAws_json1_0CancelComponentDeploymentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1562,8 +1564,7 @@ const deserializeAws_json1_0CancelEnvironmentDeploymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1585,10 +1586,12 @@ const deserializeAws_json1_0CancelEnvironmentDeploymentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1620,8 +1623,7 @@ const deserializeAws_json1_0CancelServiceInstanceDeploymentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1643,10 +1645,12 @@ const deserializeAws_json1_0CancelServiceInstanceDeploymentCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1678,8 +1682,7 @@ const deserializeAws_json1_0CancelServicePipelineDeploymentCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1701,10 +1704,12 @@ const deserializeAws_json1_0CancelServicePipelineDeploymentCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1736,8 +1741,7 @@ const deserializeAws_json1_0CreateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1762,10 +1766,12 @@ const deserializeAws_json1_0CreateComponentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1797,8 +1803,7 @@ const deserializeAws_json1_0CreateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1823,10 +1828,12 @@ const deserializeAws_json1_0CreateEnvironmentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1858,8 +1865,7 @@ const deserializeAws_json1_0CreateEnvironmentAccountConnectionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1881,10 +1887,12 @@ const deserializeAws_json1_0CreateEnvironmentAccountConnectionCommandError = asy throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1916,8 +1924,7 @@ const deserializeAws_json1_0CreateEnvironmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -1939,10 +1946,12 @@ const deserializeAws_json1_0CreateEnvironmentTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1974,8 +1983,7 @@ const deserializeAws_json1_0CreateEnvironmentTemplateVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2000,10 +2008,12 @@ const deserializeAws_json1_0CreateEnvironmentTemplateVersionCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2035,8 +2045,7 @@ const deserializeAws_json1_0CreateRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2058,10 +2067,12 @@ const deserializeAws_json1_0CreateRepositoryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2093,8 +2104,7 @@ const deserializeAws_json1_0CreateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2119,10 +2129,12 @@ const deserializeAws_json1_0CreateServiceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2154,8 +2166,7 @@ const deserializeAws_json1_0CreateServiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2177,10 +2188,12 @@ const deserializeAws_json1_0CreateServiceTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2212,8 +2225,7 @@ const deserializeAws_json1_0CreateServiceTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2238,10 +2250,12 @@ const deserializeAws_json1_0CreateServiceTemplateVersionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,8 +2287,7 @@ const deserializeAws_json1_0CreateTemplateSyncConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2296,10 +2309,12 @@ const deserializeAws_json1_0CreateTemplateSyncConfigCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2331,8 +2346,7 @@ const deserializeAws_json1_0DeleteComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2354,10 +2368,12 @@ const deserializeAws_json1_0DeleteComponentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2389,8 +2405,7 @@ const deserializeAws_json1_0DeleteEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2412,10 +2427,12 @@ const deserializeAws_json1_0DeleteEnvironmentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2447,8 +2464,7 @@ const deserializeAws_json1_0DeleteEnvironmentAccountConnectionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2470,10 +2486,12 @@ const deserializeAws_json1_0DeleteEnvironmentAccountConnectionCommandError = asy throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2505,8 +2523,7 @@ const deserializeAws_json1_0DeleteEnvironmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2528,10 +2545,12 @@ const deserializeAws_json1_0DeleteEnvironmentTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2563,8 +2582,7 @@ const deserializeAws_json1_0DeleteEnvironmentTemplateVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2586,10 +2604,12 @@ const deserializeAws_json1_0DeleteEnvironmentTemplateVersionCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2621,8 +2641,7 @@ const deserializeAws_json1_0DeleteRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2644,10 +2663,12 @@ const deserializeAws_json1_0DeleteRepositoryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2679,8 +2700,7 @@ const deserializeAws_json1_0DeleteServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2702,10 +2722,12 @@ const deserializeAws_json1_0DeleteServiceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2737,8 +2759,7 @@ const deserializeAws_json1_0DeleteServiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2760,10 +2781,12 @@ const deserializeAws_json1_0DeleteServiceTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2795,8 +2818,7 @@ const deserializeAws_json1_0DeleteServiceTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2818,10 +2840,12 @@ const deserializeAws_json1_0DeleteServiceTemplateVersionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2853,8 +2877,7 @@ const deserializeAws_json1_0DeleteTemplateSyncConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2876,10 +2899,12 @@ const deserializeAws_json1_0DeleteTemplateSyncConfigCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2911,8 +2936,7 @@ const deserializeAws_json1_0GetAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2931,10 +2955,12 @@ const deserializeAws_json1_0GetAccountSettingsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2966,8 +2992,7 @@ const deserializeAws_json1_0GetComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -2986,10 +3011,12 @@ const deserializeAws_json1_0GetComponentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3021,8 +3048,7 @@ const deserializeAws_json1_0GetEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3041,10 +3067,12 @@ const deserializeAws_json1_0GetEnvironmentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3076,8 +3104,7 @@ const deserializeAws_json1_0GetEnvironmentAccountConnectionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3096,10 +3123,12 @@ const deserializeAws_json1_0GetEnvironmentAccountConnectionCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3131,8 +3160,7 @@ const deserializeAws_json1_0GetEnvironmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3151,10 +3179,12 @@ const deserializeAws_json1_0GetEnvironmentTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3186,8 +3216,7 @@ const deserializeAws_json1_0GetEnvironmentTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3206,10 +3235,12 @@ const deserializeAws_json1_0GetEnvironmentTemplateVersionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3241,8 +3272,7 @@ const deserializeAws_json1_0GetRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3261,10 +3291,12 @@ const deserializeAws_json1_0GetRepositoryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3296,8 +3328,7 @@ const deserializeAws_json1_0GetRepositorySyncStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3316,10 +3347,12 @@ const deserializeAws_json1_0GetRepositorySyncStatusCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3351,8 +3384,7 @@ const deserializeAws_json1_0GetServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3371,10 +3403,12 @@ const deserializeAws_json1_0GetServiceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3406,8 +3440,7 @@ const deserializeAws_json1_0GetServiceInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3426,10 +3459,12 @@ const deserializeAws_json1_0GetServiceInstanceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3461,8 +3496,7 @@ const deserializeAws_json1_0GetServiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3481,10 +3515,12 @@ const deserializeAws_json1_0GetServiceTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3516,8 +3552,7 @@ const deserializeAws_json1_0GetServiceTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3536,10 +3571,12 @@ const deserializeAws_json1_0GetServiceTemplateVersionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3571,8 +3608,7 @@ const deserializeAws_json1_0GetTemplateSyncConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3591,10 +3627,12 @@ const deserializeAws_json1_0GetTemplateSyncConfigCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3626,8 +3664,7 @@ const deserializeAws_json1_0GetTemplateSyncStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3646,10 +3683,12 @@ const deserializeAws_json1_0GetTemplateSyncStatusCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3681,8 +3720,7 @@ const deserializeAws_json1_0ListComponentOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3701,10 +3739,12 @@ const deserializeAws_json1_0ListComponentOutputsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3736,8 +3776,7 @@ const deserializeAws_json1_0ListComponentProvisionedResourcesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3756,10 +3795,12 @@ const deserializeAws_json1_0ListComponentProvisionedResourcesCommandError = asyn throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3791,8 +3832,7 @@ const deserializeAws_json1_0ListComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3808,10 +3848,12 @@ const deserializeAws_json1_0ListComponentsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3843,8 +3885,7 @@ const deserializeAws_json1_0ListEnvironmentAccountConnectionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3860,10 +3901,12 @@ const deserializeAws_json1_0ListEnvironmentAccountConnectionsCommandError = asyn throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3895,8 +3938,7 @@ const deserializeAws_json1_0ListEnvironmentOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3915,10 +3957,12 @@ const deserializeAws_json1_0ListEnvironmentOutputsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3950,8 +3994,7 @@ const deserializeAws_json1_0ListEnvironmentProvisionedResourcesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -3970,10 +4013,12 @@ const deserializeAws_json1_0ListEnvironmentProvisionedResourcesCommandError = as throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4005,8 +4050,7 @@ const deserializeAws_json1_0ListEnvironmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4025,10 +4069,12 @@ const deserializeAws_json1_0ListEnvironmentsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4060,8 +4106,7 @@ const deserializeAws_json1_0ListEnvironmentTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4077,10 +4122,12 @@ const deserializeAws_json1_0ListEnvironmentTemplatesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4112,8 +4159,7 @@ const deserializeAws_json1_0ListEnvironmentTemplateVersionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4132,10 +4178,12 @@ const deserializeAws_json1_0ListEnvironmentTemplateVersionsCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4167,8 +4215,7 @@ const deserializeAws_json1_0ListRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4187,10 +4234,12 @@ const deserializeAws_json1_0ListRepositoriesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4222,8 +4271,7 @@ const deserializeAws_json1_0ListRepositorySyncDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4239,10 +4287,12 @@ const deserializeAws_json1_0ListRepositorySyncDefinitionsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4274,8 +4324,7 @@ const deserializeAws_json1_0ListServiceInstanceOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4294,10 +4343,12 @@ const deserializeAws_json1_0ListServiceInstanceOutputsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4329,8 +4380,7 @@ const deserializeAws_json1_0ListServiceInstanceProvisionedResourcesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4349,10 +4399,12 @@ const deserializeAws_json1_0ListServiceInstanceProvisionedResourcesCommandError throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4384,8 +4436,7 @@ const deserializeAws_json1_0ListServiceInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4404,10 +4455,12 @@ const deserializeAws_json1_0ListServiceInstancesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4439,8 +4492,7 @@ const deserializeAws_json1_0ListServicePipelineOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4459,10 +4511,12 @@ const deserializeAws_json1_0ListServicePipelineOutputsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4494,8 +4548,7 @@ const deserializeAws_json1_0ListServicePipelineProvisionedResourcesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4514,10 +4567,12 @@ const deserializeAws_json1_0ListServicePipelineProvisionedResourcesCommandError throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4549,8 +4604,7 @@ const deserializeAws_json1_0ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4566,10 +4620,12 @@ const deserializeAws_json1_0ListServicesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4601,8 +4657,7 @@ const deserializeAws_json1_0ListServiceTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4618,10 +4673,12 @@ const deserializeAws_json1_0ListServiceTemplatesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4653,8 +4710,7 @@ const deserializeAws_json1_0ListServiceTemplateVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4673,10 +4729,12 @@ const deserializeAws_json1_0ListServiceTemplateVersionsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4708,8 +4766,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4728,10 +4785,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4763,8 +4822,7 @@ const deserializeAws_json1_0NotifyResourceDeploymentStatusChangeCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4789,10 +4847,12 @@ const deserializeAws_json1_0NotifyResourceDeploymentStatusChangeCommandError = a throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4824,8 +4884,7 @@ const deserializeAws_json1_0RejectEnvironmentAccountConnectionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4847,10 +4906,12 @@ const deserializeAws_json1_0RejectEnvironmentAccountConnectionCommandError = asy throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4882,8 +4943,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4905,10 +4965,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4940,8 +5002,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -4963,10 +5024,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4998,8 +5061,7 @@ const deserializeAws_json1_0UpdateAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5018,10 +5080,12 @@ const deserializeAws_json1_0UpdateAccountSettingsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5053,8 +5117,7 @@ const deserializeAws_json1_0UpdateComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5079,10 +5142,12 @@ const deserializeAws_json1_0UpdateComponentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5114,8 +5179,7 @@ const deserializeAws_json1_0UpdateEnvironmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5137,10 +5201,12 @@ const deserializeAws_json1_0UpdateEnvironmentCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5172,8 +5238,7 @@ const deserializeAws_json1_0UpdateEnvironmentAccountConnectionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5195,10 +5260,12 @@ const deserializeAws_json1_0UpdateEnvironmentAccountConnectionCommandError = asy throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5230,8 +5297,7 @@ const deserializeAws_json1_0UpdateEnvironmentTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5253,10 +5319,12 @@ const deserializeAws_json1_0UpdateEnvironmentTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5288,8 +5356,7 @@ const deserializeAws_json1_0UpdateEnvironmentTemplateVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5311,10 +5378,12 @@ const deserializeAws_json1_0UpdateEnvironmentTemplateVersionCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5346,8 +5415,7 @@ const deserializeAws_json1_0UpdateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5372,10 +5440,12 @@ const deserializeAws_json1_0UpdateServiceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5407,8 +5477,7 @@ const deserializeAws_json1_0UpdateServiceInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5430,10 +5499,12 @@ const deserializeAws_json1_0UpdateServiceInstanceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5465,8 +5536,7 @@ const deserializeAws_json1_0UpdateServicePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5488,10 +5558,12 @@ const deserializeAws_json1_0UpdateServicePipelineCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5523,8 +5595,7 @@ const deserializeAws_json1_0UpdateServiceTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5546,10 +5617,12 @@ const deserializeAws_json1_0UpdateServiceTemplateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5581,8 +5654,7 @@ const deserializeAws_json1_0UpdateServiceTemplateVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5604,10 +5676,12 @@ const deserializeAws_json1_0UpdateServiceTemplateVersionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5639,8 +5713,7 @@ const deserializeAws_json1_0UpdateTemplateSyncConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.proton#AccessDeniedException": @@ -5662,10 +5735,12 @@ const deserializeAws_json1_0UpdateTemplateSyncConfigCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8634,7 +8709,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8660,6 +8735,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-qldb-session/src/protocols/Aws_json1_0.ts b/clients/client-qldb-session/src/protocols/Aws_json1_0.ts index 13cea5b4b7685..36a2562c74a98 100644 --- a/clients/client-qldb-session/src/protocols/Aws_json1_0.ts +++ b/clients/client-qldb-session/src/protocols/Aws_json1_0.ts @@ -82,8 +82,7 @@ const deserializeAws_json1_0SendCommandCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.qldbsession#BadRequestException": @@ -105,10 +104,12 @@ const deserializeAws_json1_0SendCommandCommandError = async ( throw await deserializeAws_json1_0RateExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -552,7 +553,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -578,6 +579,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-qldb/src/protocols/Aws_restJson1.ts b/clients/client-qldb/src/protocols/Aws_restJson1.ts index 8e1b00dd58ce7..e3f567ffe0d70 100644 --- a/clients/client-qldb/src/protocols/Aws_restJson1.ts +++ b/clients/client-qldb/src/protocols/Aws_restJson1.ts @@ -788,8 +788,7 @@ const deserializeAws_restJson1CancelJournalKinesisStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -802,10 +801,12 @@ const deserializeAws_restJson1CancelJournalKinesisStreamCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -862,8 +863,7 @@ const deserializeAws_restJson1CreateLedgerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -879,10 +879,12 @@ const deserializeAws_restJson1CreateLedgerCommandError = async ( throw await deserializeAws_restJson1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -911,8 +913,7 @@ const deserializeAws_restJson1DeleteLedgerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -928,10 +929,12 @@ const deserializeAws_restJson1DeleteLedgerCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -964,8 +967,7 @@ const deserializeAws_restJson1DescribeJournalKinesisStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -978,10 +980,12 @@ const deserializeAws_restJson1DescribeJournalKinesisStreamCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1014,18 +1018,19 @@ const deserializeAws_restJson1DescribeJournalS3ExportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.qldb#ResourceNotFoundException": throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1085,8 +1090,7 @@ const deserializeAws_restJson1DescribeLedgerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1096,10 +1100,12 @@ const deserializeAws_restJson1DescribeLedgerCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1132,8 +1138,7 @@ const deserializeAws_restJson1ExportJournalToS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.qldb#ResourceNotFoundException": @@ -1143,10 +1148,12 @@ const deserializeAws_restJson1ExportJournalToS3CommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1183,8 +1190,7 @@ const deserializeAws_restJson1GetBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1197,10 +1203,12 @@ const deserializeAws_restJson1GetBlockCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1237,8 +1245,7 @@ const deserializeAws_restJson1GetDigestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1251,10 +1258,12 @@ const deserializeAws_restJson1GetDigestCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1291,8 +1300,7 @@ const deserializeAws_restJson1GetRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1305,10 +1313,12 @@ const deserializeAws_restJson1GetRevisionCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1345,8 +1355,7 @@ const deserializeAws_restJson1ListJournalKinesisStreamsForLedgerCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1359,10 +1368,12 @@ const deserializeAws_restJson1ListJournalKinesisStreamsForLedgerCommandError = a throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1399,15 +1410,16 @@ const deserializeAws_restJson1ListJournalS3ExportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1444,15 +1456,16 @@ const deserializeAws_restJson1ListJournalS3ExportsForLedgerCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1489,15 +1502,16 @@ const deserializeAws_restJson1ListLedgersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1530,8 +1544,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1541,10 +1554,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1592,7 @@ const deserializeAws_restJson1StreamJournalToKinesisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1591,10 +1605,12 @@ const deserializeAws_restJson1StreamJournalToKinesisCommandError = async ( throw await deserializeAws_restJson1ResourcePreconditionNotMetExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1623,8 +1639,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1634,10 +1649,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1666,8 +1683,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1677,10 +1693,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1736,8 +1754,7 @@ const deserializeAws_restJson1UpdateLedgerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1747,10 +1764,12 @@ const deserializeAws_restJson1UpdateLedgerCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1791,8 +1810,7 @@ const deserializeAws_restJson1UpdateLedgerPermissionsModeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.qldb#InvalidParameterException": @@ -1802,10 +1820,12 @@ const deserializeAws_restJson1UpdateLedgerPermissionsModeCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2198,7 +2218,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2224,6 +2244,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-quicksight/src/protocols/Aws_restJson1.ts b/clients/client-quicksight/src/protocols/Aws_restJson1.ts index 3784035fd45a7..976c0e6876c03 100644 --- a/clients/client-quicksight/src/protocols/Aws_restJson1.ts +++ b/clients/client-quicksight/src/protocols/Aws_restJson1.ts @@ -5936,8 +5936,7 @@ const deserializeAws_restJson1CancelIngestionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -5959,10 +5958,12 @@ const deserializeAws_restJson1CancelIngestionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6015,8 +6016,7 @@ const deserializeAws_restJson1CreateAccountCustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6044,10 +6044,12 @@ const deserializeAws_restJson1CreateAccountCustomizationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6096,8 +6098,7 @@ const deserializeAws_restJson1CreateAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -6122,10 +6123,12 @@ const deserializeAws_restJson1CreateAnalysisCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6178,8 +6181,7 @@ const deserializeAws_restJson1CreateDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -6204,10 +6206,12 @@ const deserializeAws_restJson1CreateDashboardCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6260,8 +6264,7 @@ const deserializeAws_restJson1CreateDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6292,10 +6295,12 @@ const deserializeAws_restJson1CreateDataSetCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6344,8 +6349,7 @@ const deserializeAws_restJson1CreateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6373,10 +6377,12 @@ const deserializeAws_restJson1CreateDataSourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6421,8 +6427,7 @@ const deserializeAws_restJson1CreateFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6453,10 +6458,12 @@ const deserializeAws_restJson1CreateFolderCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6497,8 +6504,7 @@ const deserializeAws_restJson1CreateFolderMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6526,10 +6532,12 @@ const deserializeAws_restJson1CreateFolderMembershipCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6570,8 +6578,7 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6602,10 +6609,12 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6646,8 +6655,7 @@ const deserializeAws_restJson1CreateGroupMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6672,10 +6680,12 @@ const deserializeAws_restJson1CreateGroupMembershipCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6732,8 +6742,7 @@ const deserializeAws_restJson1CreateIAMPolicyAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6758,10 +6767,12 @@ const deserializeAws_restJson1CreateIAMPolicyAssignmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6810,8 +6821,7 @@ const deserializeAws_restJson1CreateIngestionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6836,10 +6846,12 @@ const deserializeAws_restJson1CreateIngestionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6896,8 +6908,7 @@ const deserializeAws_restJson1CreateNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -6931,10 +6942,12 @@ const deserializeAws_restJson1CreateNamespaceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6987,8 +7000,7 @@ const deserializeAws_restJson1CreateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7019,10 +7031,12 @@ const deserializeAws_restJson1CreateTemplateCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7063,8 +7077,7 @@ const deserializeAws_restJson1CreateTemplateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -7089,10 +7102,12 @@ const deserializeAws_restJson1CreateTemplateAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7145,8 +7160,7 @@ const deserializeAws_restJson1CreateThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7174,10 +7188,12 @@ const deserializeAws_restJson1CreateThemeCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7218,8 +7234,7 @@ const deserializeAws_restJson1CreateThemeAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -7247,10 +7262,12 @@ const deserializeAws_restJson1CreateThemeAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7287,8 +7304,7 @@ const deserializeAws_restJson1DeleteAccountCustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7313,10 +7329,12 @@ const deserializeAws_restJson1DeleteAccountCustomizationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7365,8 +7383,7 @@ const deserializeAws_restJson1DeleteAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -7388,10 +7405,12 @@ const deserializeAws_restJson1DeleteAnalysisCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7436,8 +7455,7 @@ const deserializeAws_restJson1DeleteDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -7459,10 +7477,12 @@ const deserializeAws_restJson1DeleteDashboardCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7507,8 +7527,7 @@ const deserializeAws_restJson1DeleteDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7527,10 +7546,12 @@ const deserializeAws_restJson1DeleteDataSetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7575,8 +7596,7 @@ const deserializeAws_restJson1DeleteDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7595,10 +7615,12 @@ const deserializeAws_restJson1DeleteDataSourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7643,8 +7665,7 @@ const deserializeAws_restJson1DeleteFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7672,10 +7693,12 @@ const deserializeAws_restJson1DeleteFolderCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7712,8 +7735,7 @@ const deserializeAws_restJson1DeleteFolderMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7735,10 +7757,12 @@ const deserializeAws_restJson1DeleteFolderMembershipCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7775,8 +7799,7 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7801,10 +7824,12 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7841,8 +7866,7 @@ const deserializeAws_restJson1DeleteGroupMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7867,10 +7891,12 @@ const deserializeAws_restJson1DeleteGroupMembershipCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7911,8 +7937,7 @@ const deserializeAws_restJson1DeleteIAMPolicyAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -7937,10 +7962,12 @@ const deserializeAws_restJson1DeleteIAMPolicyAssignmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7977,8 +8004,7 @@ const deserializeAws_restJson1DeleteNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8003,10 +8029,12 @@ const deserializeAws_restJson1DeleteNamespaceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8051,8 +8079,7 @@ const deserializeAws_restJson1DeleteTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -8077,10 +8104,12 @@ const deserializeAws_restJson1DeleteTemplateCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8129,8 +8158,7 @@ const deserializeAws_restJson1DeleteTemplateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -8149,10 +8177,12 @@ const deserializeAws_restJson1DeleteTemplateAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8197,8 +8227,7 @@ const deserializeAws_restJson1DeleteThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8223,10 +8252,12 @@ const deserializeAws_restJson1DeleteThemeCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8275,8 +8306,7 @@ const deserializeAws_restJson1DeleteThemeAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -8298,10 +8328,12 @@ const deserializeAws_restJson1DeleteThemeAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8338,8 +8370,7 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8364,10 +8395,12 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8404,8 +8437,7 @@ const deserializeAws_restJson1DeleteUserByPrincipalIdCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8430,10 +8462,12 @@ const deserializeAws_restJson1DeleteUserByPrincipalIdCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8486,8 +8520,7 @@ const deserializeAws_restJson1DescribeAccountCustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8509,10 +8542,12 @@ const deserializeAws_restJson1DescribeAccountCustomizationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8553,8 +8588,7 @@ const deserializeAws_restJson1DescribeAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8576,10 +8610,12 @@ const deserializeAws_restJson1DescribeAccountSettingsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8620,8 +8656,7 @@ const deserializeAws_restJson1DescribeAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8643,10 +8678,12 @@ const deserializeAws_restJson1DescribeAnalysisCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8695,8 +8732,7 @@ const deserializeAws_restJson1DescribeAnalysisPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -8715,10 +8751,12 @@ const deserializeAws_restJson1DescribeAnalysisPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8759,8 +8797,7 @@ const deserializeAws_restJson1DescribeDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8782,10 +8819,12 @@ const deserializeAws_restJson1DescribeDashboardCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8841,8 +8880,7 @@ const deserializeAws_restJson1DescribeDashboardPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -8861,10 +8899,12 @@ const deserializeAws_restJson1DescribeDashboardPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8905,8 +8945,7 @@ const deserializeAws_restJson1DescribeDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8925,10 +8964,12 @@ const deserializeAws_restJson1DescribeDataSetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8977,8 +9018,7 @@ const deserializeAws_restJson1DescribeDataSetPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -8997,10 +9037,12 @@ const deserializeAws_restJson1DescribeDataSetPermissionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9041,8 +9083,7 @@ const deserializeAws_restJson1DescribeDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9061,10 +9102,12 @@ const deserializeAws_restJson1DescribeDataSourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9113,8 +9156,7 @@ const deserializeAws_restJson1DescribeDataSourcePermissionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9133,10 +9175,12 @@ const deserializeAws_restJson1DescribeDataSourcePermissionsCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9177,8 +9221,7 @@ const deserializeAws_restJson1DescribeFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9200,10 +9243,12 @@ const deserializeAws_restJson1DescribeFolderCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9252,8 +9297,7 @@ const deserializeAws_restJson1DescribeFolderPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9275,10 +9319,12 @@ const deserializeAws_restJson1DescribeFolderPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9327,8 +9373,7 @@ const deserializeAws_restJson1DescribeFolderResolvedPermissionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9350,10 +9395,12 @@ const deserializeAws_restJson1DescribeFolderResolvedPermissionsCommandError = as throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9394,8 +9441,7 @@ const deserializeAws_restJson1DescribeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9420,10 +9466,12 @@ const deserializeAws_restJson1DescribeGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9464,8 +9512,7 @@ const deserializeAws_restJson1DescribeGroupMembershipCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9490,10 +9537,12 @@ const deserializeAws_restJson1DescribeGroupMembershipCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9534,8 +9583,7 @@ const deserializeAws_restJson1DescribeIAMPolicyAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9557,10 +9605,12 @@ const deserializeAws_restJson1DescribeIAMPolicyAssignmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9601,8 +9651,7 @@ const deserializeAws_restJson1DescribeIngestionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9624,10 +9673,12 @@ const deserializeAws_restJson1DescribeIngestionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9676,8 +9727,7 @@ const deserializeAws_restJson1DescribeIpRestrictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9696,10 +9746,12 @@ const deserializeAws_restJson1DescribeIpRestrictionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9740,8 +9792,7 @@ const deserializeAws_restJson1DescribeNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9763,10 +9814,12 @@ const deserializeAws_restJson1DescribeNamespaceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9807,8 +9860,7 @@ const deserializeAws_restJson1DescribeTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -9836,10 +9888,12 @@ const deserializeAws_restJson1DescribeTemplateCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9880,8 +9934,7 @@ const deserializeAws_restJson1DescribeTemplateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -9897,10 +9950,12 @@ const deserializeAws_restJson1DescribeTemplateAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9949,8 +10004,7 @@ const deserializeAws_restJson1DescribeTemplatePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -9972,10 +10026,12 @@ const deserializeAws_restJson1DescribeTemplatePermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10016,8 +10072,7 @@ const deserializeAws_restJson1DescribeThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10042,10 +10097,12 @@ const deserializeAws_restJson1DescribeThemeCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10086,8 +10143,7 @@ const deserializeAws_restJson1DescribeThemeAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -10109,10 +10165,12 @@ const deserializeAws_restJson1DescribeThemeAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10161,8 +10219,7 @@ const deserializeAws_restJson1DescribeThemePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10184,10 +10241,12 @@ const deserializeAws_restJson1DescribeThemePermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10228,8 +10287,7 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10254,10 +10312,12 @@ const deserializeAws_restJson1DescribeUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10298,8 +10358,7 @@ const deserializeAws_restJson1GenerateEmbedUrlForAnonymousUserCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10327,10 +10386,12 @@ const deserializeAws_restJson1GenerateEmbedUrlForAnonymousUserCommandError = asy throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10371,8 +10432,7 @@ const deserializeAws_restJson1GenerateEmbedUrlForRegisteredUserCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10403,10 +10463,12 @@ const deserializeAws_restJson1GenerateEmbedUrlForRegisteredUserCommandError = as throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10447,8 +10509,7 @@ const deserializeAws_restJson1GetDashboardEmbedUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10488,10 +10549,12 @@ const deserializeAws_restJson1GetDashboardEmbedUrlCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10532,8 +10595,7 @@ const deserializeAws_restJson1GetSessionEmbedUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10564,10 +10626,12 @@ const deserializeAws_restJson1GetSessionEmbedUrlCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10612,8 +10676,7 @@ const deserializeAws_restJson1ListAnalysesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -10629,10 +10692,12 @@ const deserializeAws_restJson1ListAnalysesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10677,8 +10742,7 @@ const deserializeAws_restJson1ListDashboardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -10694,10 +10758,12 @@ const deserializeAws_restJson1ListDashboardsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10745,8 +10811,7 @@ const deserializeAws_restJson1ListDashboardVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -10768,10 +10833,12 @@ const deserializeAws_restJson1ListDashboardVersionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10816,8 +10883,7 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10836,10 +10902,12 @@ const deserializeAws_restJson1ListDataSetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10884,8 +10952,7 @@ const deserializeAws_restJson1ListDataSourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10904,10 +10971,12 @@ const deserializeAws_restJson1ListDataSourcesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10952,8 +11021,7 @@ const deserializeAws_restJson1ListFolderMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -10978,10 +11046,12 @@ const deserializeAws_restJson1ListFolderMembersCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11026,8 +11096,7 @@ const deserializeAws_restJson1ListFoldersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11052,10 +11121,12 @@ const deserializeAws_restJson1ListFoldersCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11100,8 +11171,7 @@ const deserializeAws_restJson1ListGroupMembershipsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11129,10 +11199,12 @@ const deserializeAws_restJson1ListGroupMembershipsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11177,8 +11249,7 @@ const deserializeAws_restJson1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11206,10 +11277,12 @@ const deserializeAws_restJson1ListGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11257,8 +11330,7 @@ const deserializeAws_restJson1ListIAMPolicyAssignmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11280,10 +11352,12 @@ const deserializeAws_restJson1ListIAMPolicyAssignmentsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11328,8 +11402,7 @@ const deserializeAws_restJson1ListIAMPolicyAssignmentsForUserCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11354,10 +11427,12 @@ const deserializeAws_restJson1ListIAMPolicyAssignmentsForUserCommandError = asyn throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11402,8 +11477,7 @@ const deserializeAws_restJson1ListIngestionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11428,10 +11502,12 @@ const deserializeAws_restJson1ListIngestionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11476,8 +11552,7 @@ const deserializeAws_restJson1ListNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11505,10 +11580,12 @@ const deserializeAws_restJson1ListNamespacesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11549,8 +11626,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11569,10 +11645,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11617,8 +11695,7 @@ const deserializeAws_restJson1ListTemplateAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -11637,10 +11714,12 @@ const deserializeAws_restJson1ListTemplateAliasesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11685,8 +11764,7 @@ const deserializeAws_restJson1ListTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -11708,10 +11786,12 @@ const deserializeAws_restJson1ListTemplatesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11759,8 +11839,7 @@ const deserializeAws_restJson1ListTemplateVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -11782,10 +11861,12 @@ const deserializeAws_restJson1ListTemplateVersionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11830,8 +11911,7 @@ const deserializeAws_restJson1ListThemeAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -11856,10 +11936,12 @@ const deserializeAws_restJson1ListThemeAliasesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11904,8 +11986,7 @@ const deserializeAws_restJson1ListThemesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -11930,10 +12011,12 @@ const deserializeAws_restJson1ListThemesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11981,8 +12064,7 @@ const deserializeAws_restJson1ListThemeVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12007,10 +12089,12 @@ const deserializeAws_restJson1ListThemeVersionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12055,8 +12139,7 @@ const deserializeAws_restJson1ListUserGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12081,10 +12164,12 @@ const deserializeAws_restJson1ListUserGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12129,8 +12214,7 @@ const deserializeAws_restJson1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12158,10 +12242,12 @@ const deserializeAws_restJson1ListUsersCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12206,8 +12292,7 @@ const deserializeAws_restJson1RegisterUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12238,10 +12323,12 @@ const deserializeAws_restJson1RegisterUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12286,8 +12373,7 @@ const deserializeAws_restJson1RestoreAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -12309,10 +12395,12 @@ const deserializeAws_restJson1RestoreAnalysisCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12357,8 +12445,7 @@ const deserializeAws_restJson1SearchAnalysesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -12380,10 +12467,12 @@ const deserializeAws_restJson1SearchAnalysesCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12428,8 +12517,7 @@ const deserializeAws_restJson1SearchDashboardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailureException": case "com.amazonaws.quicksight#InternalFailureException": @@ -12451,10 +12539,12 @@ const deserializeAws_restJson1SearchDashboardsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12499,8 +12589,7 @@ const deserializeAws_restJson1SearchFoldersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12525,10 +12614,12 @@ const deserializeAws_restJson1SearchFoldersCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12573,8 +12664,7 @@ const deserializeAws_restJson1SearchGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12602,10 +12692,12 @@ const deserializeAws_restJson1SearchGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12642,8 +12734,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12665,10 +12756,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12705,8 +12798,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12725,10 +12817,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12781,8 +12875,7 @@ const deserializeAws_restJson1UpdateAccountCustomizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12807,10 +12900,12 @@ const deserializeAws_restJson1UpdateAccountCustomizationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12847,8 +12942,7 @@ const deserializeAws_restJson1UpdateAccountSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -12870,10 +12964,12 @@ const deserializeAws_restJson1UpdateAccountSettingsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12922,8 +13018,7 @@ const deserializeAws_restJson1UpdateAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -12948,10 +13043,12 @@ const deserializeAws_restJson1UpdateAnalysisCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13000,8 +13097,7 @@ const deserializeAws_restJson1UpdateAnalysisPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -13023,10 +13119,12 @@ const deserializeAws_restJson1UpdateAnalysisPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13079,8 +13177,7 @@ const deserializeAws_restJson1UpdateDashboardCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -13105,10 +13202,12 @@ const deserializeAws_restJson1UpdateDashboardCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13164,8 +13263,7 @@ const deserializeAws_restJson1UpdateDashboardPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -13187,10 +13285,12 @@ const deserializeAws_restJson1UpdateDashboardPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13235,8 +13335,7 @@ const deserializeAws_restJson1UpdateDashboardPublishedVersionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -13258,10 +13357,12 @@ const deserializeAws_restJson1UpdateDashboardPublishedVersionCommandError = asyn throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13314,8 +13415,7 @@ const deserializeAws_restJson1UpdateDataSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13343,10 +13443,12 @@ const deserializeAws_restJson1UpdateDataSetCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13391,8 +13493,7 @@ const deserializeAws_restJson1UpdateDataSetPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13414,10 +13515,12 @@ const deserializeAws_restJson1UpdateDataSetPermissionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13466,8 +13569,7 @@ const deserializeAws_restJson1UpdateDataSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13489,10 +13591,12 @@ const deserializeAws_restJson1UpdateDataSourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13537,8 +13641,7 @@ const deserializeAws_restJson1UpdateDataSourcePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13560,10 +13663,12 @@ const deserializeAws_restJson1UpdateDataSourcePermissionsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13608,8 +13713,7 @@ const deserializeAws_restJson1UpdateFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13637,10 +13741,12 @@ const deserializeAws_restJson1UpdateFolderCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13689,8 +13795,7 @@ const deserializeAws_restJson1UpdateFolderPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13715,10 +13820,12 @@ const deserializeAws_restJson1UpdateFolderPermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13759,8 +13866,7 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13785,10 +13891,12 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13845,8 +13953,7 @@ const deserializeAws_restJson1UpdateIAMPolicyAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13871,10 +13978,12 @@ const deserializeAws_restJson1UpdateIAMPolicyAssignmentCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13915,8 +14024,7 @@ const deserializeAws_restJson1UpdateIpRestrictionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -13938,10 +14046,12 @@ const deserializeAws_restJson1UpdateIpRestrictionCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13978,8 +14088,7 @@ const deserializeAws_restJson1UpdatePublicSharingSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -14001,10 +14110,12 @@ const deserializeAws_restJson1UpdatePublicSharingSettingsCommandError = async ( throw await deserializeAws_restJson1UnsupportedPricingPlanExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14057,8 +14168,7 @@ const deserializeAws_restJson1UpdateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -14086,10 +14196,12 @@ const deserializeAws_restJson1UpdateTemplateCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14130,8 +14242,7 @@ const deserializeAws_restJson1UpdateTemplateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -14150,10 +14261,12 @@ const deserializeAws_restJson1UpdateTemplateAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14202,8 +14315,7 @@ const deserializeAws_restJson1UpdateTemplatePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -14225,10 +14337,12 @@ const deserializeAws_restJson1UpdateTemplatePermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14281,8 +14395,7 @@ const deserializeAws_restJson1UpdateThemeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -14310,10 +14423,12 @@ const deserializeAws_restJson1UpdateThemeCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14354,8 +14469,7 @@ const deserializeAws_restJson1UpdateThemeAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.quicksight#ConflictException": @@ -14380,10 +14494,12 @@ const deserializeAws_restJson1UpdateThemeAliasCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14432,8 +14548,7 @@ const deserializeAws_restJson1UpdateThemePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -14455,10 +14570,12 @@ const deserializeAws_restJson1UpdateThemePermissionsCommandError = async ( throw await deserializeAws_restJson1UnsupportedUserEditionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14499,8 +14616,7 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.quicksight#AccessDeniedException": @@ -14525,10 +14641,12 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -18616,7 +18734,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -18642,6 +18760,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ram/src/protocols/Aws_restJson1.ts b/clients/client-ram/src/protocols/Aws_restJson1.ts index a983203e82e38..fbb0569ad5fc7 100644 --- a/clients/client-ram/src/protocols/Aws_restJson1.ts +++ b/clients/client-ram/src/protocols/Aws_restJson1.ts @@ -917,8 +917,7 @@ const deserializeAws_restJson1AcceptResourceShareInvitationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -958,10 +957,12 @@ const deserializeAws_restJson1AcceptResourceShareInvitationCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1001,8 +1002,7 @@ const deserializeAws_restJson1AssociateResourceShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -1039,10 +1039,12 @@ const deserializeAws_restJson1AssociateResourceShareCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1079,8 +1081,7 @@ const deserializeAws_restJson1AssociateResourceSharePermissionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.ram#InvalidClientTokenException": @@ -1105,10 +1106,12 @@ const deserializeAws_restJson1AssociateResourceSharePermissionCommandError = asy throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1145,8 +1148,7 @@ const deserializeAws_restJson1CreateResourceShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -1183,10 +1185,12 @@ const deserializeAws_restJson1CreateResourceShareCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1223,8 +1227,7 @@ const deserializeAws_restJson1DeleteResourceShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -1255,10 +1258,12 @@ const deserializeAws_restJson1DeleteResourceShareCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1298,8 +1303,7 @@ const deserializeAws_restJson1DisassociateResourceShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -1333,10 +1337,12 @@ const deserializeAws_restJson1DisassociateResourceShareCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1373,8 +1379,7 @@ const deserializeAws_restJson1DisassociateResourceSharePermissionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClientTokenException": case "com.amazonaws.ram#InvalidClientTokenException": @@ -1402,10 +1407,12 @@ const deserializeAws_restJson1DisassociateResourceSharePermissionCommandError = throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1438,8 +1445,7 @@ const deserializeAws_restJson1EnableSharingWithAwsOrganizationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedException": case "com.amazonaws.ram#OperationNotPermittedException": @@ -1452,10 +1458,12 @@ const deserializeAws_restJson1EnableSharingWithAwsOrganizationCommandError = asy throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1488,8 +1496,7 @@ const deserializeAws_restJson1GetPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ram#InvalidParameterException": @@ -1511,10 +1518,12 @@ const deserializeAws_restJson1GetPermissionCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1551,8 +1560,7 @@ const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1574,10 +1582,12 @@ const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1617,8 +1627,7 @@ const deserializeAws_restJson1GetResourceShareAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1643,10 +1652,12 @@ const deserializeAws_restJson1GetResourceShareAssociationsCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1686,8 +1697,7 @@ const deserializeAws_restJson1GetResourceShareInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidMaxResultsException": case "com.amazonaws.ram#InvalidMaxResultsException": @@ -1715,10 +1725,12 @@ const deserializeAws_restJson1GetResourceShareInvitationsCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1755,8 +1767,7 @@ const deserializeAws_restJson1GetResourceSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1778,10 +1789,12 @@ const deserializeAws_restJson1GetResourceSharesCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1818,8 +1831,7 @@ const deserializeAws_restJson1ListPendingInvitationResourcesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1853,10 +1865,12 @@ const deserializeAws_restJson1ListPendingInvitationResourcesCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1893,8 +1907,7 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1913,10 +1926,12 @@ const deserializeAws_restJson1ListPermissionsCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,8 +1968,7 @@ const deserializeAws_restJson1ListPermissionVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -1979,10 +1993,12 @@ const deserializeAws_restJson1ListPermissionVersionsCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2019,8 +2035,7 @@ const deserializeAws_restJson1ListPrincipalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -2042,10 +2057,12 @@ const deserializeAws_restJson1ListPrincipalsCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2082,8 +2099,7 @@ const deserializeAws_restJson1ListResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -2108,10 +2124,12 @@ const deserializeAws_restJson1ListResourcesCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2148,8 +2166,7 @@ const deserializeAws_restJson1ListResourceSharePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -2174,10 +2191,12 @@ const deserializeAws_restJson1ListResourceSharePermissionsCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2214,8 +2233,7 @@ const deserializeAws_restJson1ListResourceTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.ram#InvalidNextTokenException": @@ -2231,10 +2249,12 @@ const deserializeAws_restJson1ListResourceTypesCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2267,8 +2287,7 @@ const deserializeAws_restJson1PromoteResourceShareCreatedFromPolicyCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ram#InvalidParameterException": @@ -2296,10 +2315,12 @@ const deserializeAws_restJson1PromoteResourceShareCreatedFromPolicyCommandError throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2339,8 +2360,7 @@ const deserializeAws_restJson1RejectResourceShareInvitationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -2380,10 +2400,12 @@ const deserializeAws_restJson1RejectResourceShareInvitationCommandError = async throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2412,8 +2434,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ram#InvalidParameterException": @@ -2441,10 +2462,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2473,8 +2496,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.ram#InvalidParameterException": @@ -2487,10 +2509,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2527,8 +2551,7 @@ const deserializeAws_restJson1UpdateResourceShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.ram#IdempotentParameterMismatchException": @@ -2559,10 +2582,12 @@ const deserializeAws_restJson1UpdateResourceShareCommandError = async ( throw await deserializeAws_restJson1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3361,7 +3386,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3387,6 +3412,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-rbin/src/protocols/Aws_restJson1.ts b/clients/client-rbin/src/protocols/Aws_restJson1.ts index eaf64e02cefce..e77c1d0036bf9 100644 --- a/clients/client-rbin/src/protocols/Aws_restJson1.ts +++ b/clients/client-rbin/src/protocols/Aws_restJson1.ts @@ -339,8 +339,7 @@ const deserializeAws_restJson1CreateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -353,10 +352,12 @@ const deserializeAws_restJson1CreateRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -385,8 +386,7 @@ const deserializeAws_restJson1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -399,10 +399,12 @@ const deserializeAws_restJson1DeleteRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -455,8 +457,7 @@ const deserializeAws_restJson1GetRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -469,10 +470,12 @@ const deserializeAws_restJson1GetRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -509,8 +512,7 @@ const deserializeAws_restJson1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -520,10 +522,12 @@ const deserializeAws_restJson1ListRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -556,8 +560,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -570,10 +573,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -602,8 +607,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -619,10 +623,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -651,8 +657,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -665,10 +670,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -721,8 +728,7 @@ const deserializeAws_restJson1UpdateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rbin#InternalServerException": @@ -735,10 +741,12 @@ const deserializeAws_restJson1UpdateRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -969,7 +977,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -995,6 +1003,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-rds-data/src/protocols/Aws_restJson1.ts b/clients/client-rds-data/src/protocols/Aws_restJson1.ts index 197b7abac48a9..8a6daffffc5b0 100644 --- a/clients/client-rds-data/src/protocols/Aws_restJson1.ts +++ b/clients/client-rds-data/src/protocols/Aws_restJson1.ts @@ -264,8 +264,7 @@ const deserializeAws_restJson1BatchExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -287,10 +286,12 @@ const deserializeAws_restJson1BatchExecuteStatementCommandError = async ( throw await deserializeAws_restJson1StatementTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -323,8 +324,7 @@ const deserializeAws_restJson1BeginTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -346,10 +346,12 @@ const deserializeAws_restJson1BeginTransactionCommandError = async ( throw await deserializeAws_restJson1StatementTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -382,8 +384,7 @@ const deserializeAws_restJson1CommitTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -408,10 +409,12 @@ const deserializeAws_restJson1CommitTransactionCommandError = async ( throw await deserializeAws_restJson1StatementTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -444,8 +447,7 @@ const deserializeAws_restJson1ExecuteSqlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -464,10 +466,12 @@ const deserializeAws_restJson1ExecuteSqlCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -516,8 +520,7 @@ const deserializeAws_restJson1ExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -539,10 +542,12 @@ const deserializeAws_restJson1ExecuteStatementCommandError = async ( throw await deserializeAws_restJson1StatementTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -575,8 +580,7 @@ const deserializeAws_restJson1RollbackTransactionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rdsdata#AccessDeniedException": @@ -601,10 +605,12 @@ const deserializeAws_restJson1RollbackTransactionCommandError = async ( throw await deserializeAws_restJson1StatementTimeoutExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1208,7 +1214,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1234,6 +1240,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-rds/src/protocols/Aws_query.ts b/clients/client-rds/src/protocols/Aws_query.ts index 904a27a845499..43908b318b36d 100644 --- a/clients/client-rds/src/protocols/Aws_query.ts +++ b/clients/client-rds/src/protocols/Aws_query.ts @@ -3099,8 +3099,7 @@ const deserializeAws_queryAddRoleToDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -3116,10 +3115,12 @@ const deserializeAws_queryAddRoleToDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3148,8 +3149,7 @@ const deserializeAws_queryAddRoleToDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -3165,10 +3165,12 @@ const deserializeAws_queryAddRoleToDBInstanceCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3203,8 +3205,7 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.rds#SourceNotFoundFault": @@ -3214,10 +3215,12 @@ const deserializeAws_queryAddSourceIdentifierToSubscriptionCommandError = async throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3246,8 +3249,7 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -3266,10 +3268,12 @@ const deserializeAws_queryAddTagsToResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3301,8 +3305,7 @@ const deserializeAws_queryApplyPendingMaintenanceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDBClusterStateFault": case "com.amazonaws.rds#InvalidDBClusterStateFault": @@ -3315,10 +3318,12 @@ const deserializeAws_queryApplyPendingMaintenanceActionCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3353,8 +3358,7 @@ const deserializeAws_queryAuthorizeDBSecurityGroupIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationAlreadyExistsFault": case "com.amazonaws.rds#AuthorizationAlreadyExistsFault": @@ -3370,10 +3374,12 @@ const deserializeAws_queryAuthorizeDBSecurityGroupIngressCommandError = async ( throw await deserializeAws_queryInvalidDBSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3405,8 +3411,7 @@ const deserializeAws_queryBacktrackDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -3416,10 +3421,12 @@ const deserializeAws_queryBacktrackDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3451,8 +3458,7 @@ const deserializeAws_queryCancelExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExportTaskNotFoundFault": case "com.amazonaws.rds#ExportTaskNotFoundFault": @@ -3462,10 +3468,12 @@ const deserializeAws_queryCancelExportTaskCommandError = async ( throw await deserializeAws_queryInvalidExportTaskStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3497,8 +3505,7 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.rds#DBParameterGroupAlreadyExistsFault": @@ -3511,10 +3518,12 @@ const deserializeAws_queryCopyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3546,8 +3555,7 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotAlreadyExistsFault": case "com.amazonaws.rds#DBClusterSnapshotAlreadyExistsFault": @@ -3569,10 +3577,12 @@ const deserializeAws_queryCopyDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3604,8 +3614,7 @@ const deserializeAws_queryCopyDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.rds#DBParameterGroupAlreadyExistsFault": @@ -3618,10 +3627,12 @@ const deserializeAws_queryCopyDBParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3653,8 +3664,7 @@ const deserializeAws_queryCopyDBSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomAvailabilityZoneNotFoundFault": case "com.amazonaws.rds#CustomAvailabilityZoneNotFoundFault": @@ -3676,10 +3686,12 @@ const deserializeAws_queryCopyDBSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3711,8 +3723,7 @@ const deserializeAws_queryCopyOptionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OptionGroupAlreadyExistsFault": case "com.amazonaws.rds#OptionGroupAlreadyExistsFault": @@ -3725,10 +3736,12 @@ const deserializeAws_queryCopyOptionGroupCommandError = async ( throw await deserializeAws_queryOptionGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3760,8 +3773,7 @@ const deserializeAws_queryCreateCustomDBEngineVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomDBEngineVersionAlreadyExistsFault": case "com.amazonaws.rds#CustomDBEngineVersionAlreadyExistsFault": @@ -3774,10 +3786,12 @@ const deserializeAws_queryCreateCustomDBEngineVersionCommandError = async ( throw await deserializeAws_queryKMSKeyNotAccessibleFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3809,8 +3823,7 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.rds#DBClusterAlreadyExistsFault": @@ -3868,10 +3881,12 @@ const deserializeAws_queryCreateDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3903,8 +3918,7 @@ const deserializeAws_queryCreateDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointAlreadyExistsFault": case "com.amazonaws.rds#DBClusterEndpointAlreadyExistsFault": @@ -3926,10 +3940,12 @@ const deserializeAws_queryCreateDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3961,8 +3977,7 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.rds#DBParameterGroupAlreadyExistsFault": @@ -3972,10 +3987,12 @@ const deserializeAws_queryCreateDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4007,8 +4024,7 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -4027,10 +4043,12 @@ const deserializeAws_queryCreateDBClusterSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4062,8 +4080,7 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -4127,10 +4144,12 @@ const deserializeAws_queryCreateDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4162,8 +4181,7 @@ const deserializeAws_queryCreateDBInstanceReadReplicaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceAlreadyExistsFault": case "com.amazonaws.rds#DBInstanceAlreadyExistsFault": @@ -4227,10 +4245,12 @@ const deserializeAws_queryCreateDBInstanceReadReplicaCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4262,8 +4282,7 @@ const deserializeAws_queryCreateDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupAlreadyExistsFault": case "com.amazonaws.rds#DBParameterGroupAlreadyExistsFault": @@ -4273,10 +4292,12 @@ const deserializeAws_queryCreateDBParameterGroupCommandError = async ( throw await deserializeAws_queryDBParameterGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4308,8 +4329,7 @@ const deserializeAws_queryCreateDBProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyAlreadyExistsFault": case "com.amazonaws.rds#DBProxyAlreadyExistsFault": @@ -4322,10 +4342,12 @@ const deserializeAws_queryCreateDBProxyCommandError = async ( throw await deserializeAws_queryInvalidSubnetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4357,8 +4379,7 @@ const deserializeAws_queryCreateDBProxyEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyEndpointAlreadyExistsFault": case "com.amazonaws.rds#DBProxyEndpointAlreadyExistsFault": @@ -4377,10 +4398,12 @@ const deserializeAws_queryCreateDBProxyEndpointCommandError = async ( throw await deserializeAws_queryInvalidSubnetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4412,8 +4435,7 @@ const deserializeAws_queryCreateDBSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSecurityGroupAlreadyExistsFault": case "com.amazonaws.rds#DBSecurityGroupAlreadyExistsFault": @@ -4426,10 +4448,12 @@ const deserializeAws_queryCreateDBSecurityGroupCommandError = async ( throw await deserializeAws_queryDBSecurityGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4461,8 +4485,7 @@ const deserializeAws_queryCreateDBSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -4478,10 +4501,12 @@ const deserializeAws_queryCreateDBSnapshotCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4513,8 +4538,7 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupAlreadyExistsFault": case "com.amazonaws.rds#DBSubnetGroupAlreadyExistsFault": @@ -4533,10 +4557,12 @@ const deserializeAws_queryCreateDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidSubnetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4568,8 +4594,7 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.rds#EventSubscriptionQuotaExceededFault": @@ -4594,10 +4619,12 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionCategoryNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4629,8 +4656,7 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -4646,10 +4672,12 @@ const deserializeAws_queryCreateGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4681,8 +4709,7 @@ const deserializeAws_queryCreateOptionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OptionGroupAlreadyExistsFault": case "com.amazonaws.rds#OptionGroupAlreadyExistsFault": @@ -4692,10 +4719,12 @@ const deserializeAws_queryCreateOptionGroupCommandError = async ( throw await deserializeAws_queryOptionGroupQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4727,8 +4756,7 @@ const deserializeAws_queryDeleteCustomDBEngineVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomDBEngineVersionNotFoundFault": case "com.amazonaws.rds#CustomDBEngineVersionNotFoundFault": @@ -4738,10 +4766,12 @@ const deserializeAws_queryDeleteCustomDBEngineVersionCommandError = async ( throw await deserializeAws_queryInvalidCustomDBEngineVersionStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4773,8 +4803,7 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -4793,10 +4822,12 @@ const deserializeAws_queryDeleteDBClusterCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4828,8 +4859,7 @@ const deserializeAws_queryDeleteDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointNotFoundFault": case "com.amazonaws.rds#DBClusterEndpointNotFoundFault": @@ -4842,10 +4872,12 @@ const deserializeAws_queryDeleteDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4874,8 +4906,7 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -4885,10 +4916,12 @@ const deserializeAws_queryDeleteDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4920,8 +4953,7 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.rds#DBClusterSnapshotNotFoundFault": @@ -4931,10 +4963,12 @@ const deserializeAws_queryDeleteDBClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidDBClusterSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4966,8 +5000,7 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceAutomatedBackupQuotaExceededFault": case "com.amazonaws.rds#DBInstanceAutomatedBackupQuotaExceededFault": @@ -4989,10 +5022,12 @@ const deserializeAws_queryDeleteDBInstanceCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5027,8 +5062,7 @@ const deserializeAws_queryDeleteDBInstanceAutomatedBackupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceAutomatedBackupNotFoundFault": case "com.amazonaws.rds#DBInstanceAutomatedBackupNotFoundFault": @@ -5038,10 +5072,12 @@ const deserializeAws_queryDeleteDBInstanceAutomatedBackupCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceAutomatedBackupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5070,8 +5106,7 @@ const deserializeAws_queryDeleteDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -5081,10 +5116,12 @@ const deserializeAws_queryDeleteDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5116,8 +5153,7 @@ const deserializeAws_queryDeleteDBProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": @@ -5127,10 +5163,12 @@ const deserializeAws_queryDeleteDBProxyCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5162,8 +5200,7 @@ const deserializeAws_queryDeleteDBProxyEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyEndpointNotFoundFault": case "com.amazonaws.rds#DBProxyEndpointNotFoundFault": @@ -5173,10 +5210,12 @@ const deserializeAws_queryDeleteDBProxyEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBProxyEndpointStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5205,8 +5244,7 @@ const deserializeAws_queryDeleteDBSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSecurityGroupNotFoundFault": case "com.amazonaws.rds#DBSecurityGroupNotFoundFault": @@ -5216,10 +5254,12 @@ const deserializeAws_queryDeleteDBSecurityGroupCommandError = async ( throw await deserializeAws_queryInvalidDBSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5251,8 +5291,7 @@ const deserializeAws_queryDeleteDBSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSnapshotNotFoundFault": case "com.amazonaws.rds#DBSnapshotNotFoundFault": @@ -5262,10 +5301,12 @@ const deserializeAws_queryDeleteDBSnapshotCommandError = async ( throw await deserializeAws_queryInvalidDBSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5294,8 +5335,7 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.rds#DBSubnetGroupNotFoundFault": @@ -5308,10 +5348,12 @@ const deserializeAws_queryDeleteDBSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidDBSubnetStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5343,8 +5385,7 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEventSubscriptionStateFault": case "com.amazonaws.rds#InvalidEventSubscriptionStateFault": @@ -5354,10 +5395,12 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5389,8 +5432,7 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.rds#GlobalClusterNotFoundFault": @@ -5400,10 +5442,12 @@ const deserializeAws_queryDeleteGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5432,8 +5476,7 @@ const deserializeAws_queryDeleteOptionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOptionGroupStateFault": case "com.amazonaws.rds#InvalidOptionGroupStateFault": @@ -5443,10 +5486,12 @@ const deserializeAws_queryDeleteOptionGroupCommandError = async ( throw await deserializeAws_queryOptionGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5478,8 +5523,7 @@ const deserializeAws_queryDeregisterDBProxyTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": @@ -5495,10 +5539,12 @@ const deserializeAws_queryDeregisterDBProxyTargetsCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5530,15 +5576,16 @@ const deserializeAws_queryDescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5570,18 +5617,19 @@ const deserializeAws_queryDescribeCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateNotFoundFault": case "com.amazonaws.rds#CertificateNotFoundFault": throw await deserializeAws_queryCertificateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5613,8 +5661,7 @@ const deserializeAws_queryDescribeDBClusterBacktracksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterBacktrackNotFoundFault": case "com.amazonaws.rds#DBClusterBacktrackNotFoundFault": @@ -5624,10 +5671,12 @@ const deserializeAws_queryDescribeDBClusterBacktracksCommandError = async ( throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5659,18 +5708,19 @@ const deserializeAws_queryDescribeDBClusterEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5702,18 +5752,19 @@ const deserializeAws_queryDescribeDBClusterParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5745,18 +5796,19 @@ const deserializeAws_queryDescribeDBClusterParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5788,18 +5840,19 @@ const deserializeAws_queryDescribeDBClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": throw await deserializeAws_queryDBClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5834,18 +5887,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotAttributesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.rds#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5877,18 +5931,19 @@ const deserializeAws_queryDescribeDBClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.rds#DBClusterSnapshotNotFoundFault": throw await deserializeAws_queryDBClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5920,15 +5975,16 @@ const deserializeAws_queryDescribeDBEngineVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5963,18 +6019,19 @@ const deserializeAws_queryDescribeDBInstanceAutomatedBackupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceAutomatedBackupNotFoundFault": case "com.amazonaws.rds#DBInstanceAutomatedBackupNotFoundFault": throw await deserializeAws_queryDBInstanceAutomatedBackupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6006,18 +6063,19 @@ const deserializeAws_queryDescribeDBInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": throw await deserializeAws_queryDBInstanceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6049,18 +6107,19 @@ const deserializeAws_queryDescribeDBLogFilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": throw await deserializeAws_queryDBInstanceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6092,18 +6151,19 @@ const deserializeAws_queryDescribeDBParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6135,18 +6195,19 @@ const deserializeAws_queryDescribeDBParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": throw await deserializeAws_queryDBParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6178,18 +6239,19 @@ const deserializeAws_queryDescribeDBProxiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": throw await deserializeAws_queryDBProxyNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6221,8 +6283,7 @@ const deserializeAws_queryDescribeDBProxyEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyEndpointNotFoundFault": case "com.amazonaws.rds#DBProxyEndpointNotFoundFault": @@ -6232,10 +6293,12 @@ const deserializeAws_queryDescribeDBProxyEndpointsCommandError = async ( throw await deserializeAws_queryDBProxyNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6267,8 +6330,7 @@ const deserializeAws_queryDescribeDBProxyTargetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": @@ -6281,10 +6343,12 @@ const deserializeAws_queryDescribeDBProxyTargetGroupsCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6316,8 +6380,7 @@ const deserializeAws_queryDescribeDBProxyTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": @@ -6333,10 +6396,12 @@ const deserializeAws_queryDescribeDBProxyTargetsCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6368,18 +6433,19 @@ const deserializeAws_queryDescribeDBSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSecurityGroupNotFoundFault": case "com.amazonaws.rds#DBSecurityGroupNotFoundFault": throw await deserializeAws_queryDBSecurityGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6411,18 +6477,19 @@ const deserializeAws_queryDescribeDBSnapshotAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSnapshotNotFoundFault": case "com.amazonaws.rds#DBSnapshotNotFoundFault": throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6454,18 +6521,19 @@ const deserializeAws_queryDescribeDBSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSnapshotNotFoundFault": case "com.amazonaws.rds#DBSnapshotNotFoundFault": throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6497,18 +6565,19 @@ const deserializeAws_queryDescribeDBSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupNotFoundFault": case "com.amazonaws.rds#DBSubnetGroupNotFoundFault": throw await deserializeAws_queryDBSubnetGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6543,15 +6612,16 @@ const deserializeAws_queryDescribeEngineDefaultClusterParametersCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6586,15 +6656,16 @@ const deserializeAws_queryDescribeEngineDefaultParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6626,15 +6697,16 @@ const deserializeAws_queryDescribeEventCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6666,15 +6738,16 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6706,18 +6779,19 @@ const deserializeAws_queryDescribeEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SubscriptionNotFoundFault": case "com.amazonaws.rds#SubscriptionNotFoundFault": throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6749,18 +6823,19 @@ const deserializeAws_queryDescribeExportTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExportTaskNotFoundFault": case "com.amazonaws.rds#ExportTaskNotFoundFault": throw await deserializeAws_queryExportTaskNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6792,18 +6867,19 @@ const deserializeAws_queryDescribeGlobalClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.rds#GlobalClusterNotFoundFault": throw await deserializeAws_queryGlobalClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6835,15 +6911,16 @@ const deserializeAws_queryDescribeOptionGroupOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6875,18 +6952,19 @@ const deserializeAws_queryDescribeOptionGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OptionGroupNotFoundFault": case "com.amazonaws.rds#OptionGroupNotFoundFault": throw await deserializeAws_queryOptionGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6921,15 +6999,16 @@ const deserializeAws_queryDescribeOrderableDBInstanceOptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6964,18 +7043,19 @@ const deserializeAws_queryDescribePendingMaintenanceActionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundFault": case "com.amazonaws.rds#ResourceNotFoundFault": throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7007,18 +7087,19 @@ const deserializeAws_queryDescribeReservedDBInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReservedDBInstanceNotFoundFault": case "com.amazonaws.rds#ReservedDBInstanceNotFoundFault": throw await deserializeAws_queryReservedDBInstanceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7053,18 +7134,19 @@ const deserializeAws_queryDescribeReservedDBInstancesOfferingsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReservedDBInstancesOfferingNotFoundFault": case "com.amazonaws.rds#ReservedDBInstancesOfferingNotFoundFault": throw await deserializeAws_queryReservedDBInstancesOfferingNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7096,15 +7178,16 @@ const deserializeAws_queryDescribeSourceRegionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7139,8 +7222,7 @@ const deserializeAws_queryDescribeValidDBInstanceModificationsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -7150,10 +7232,12 @@ const deserializeAws_queryDescribeValidDBInstanceModificationsCommandError = asy throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7185,8 +7269,7 @@ const deserializeAws_queryDownloadDBLogFilePortionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -7196,10 +7279,12 @@ const deserializeAws_queryDownloadDBLogFilePortionCommandError = async ( throw await deserializeAws_queryDBLogFileNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7231,8 +7316,7 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -7245,10 +7329,12 @@ const deserializeAws_queryFailoverDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7280,8 +7366,7 @@ const deserializeAws_queryFailoverGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -7297,10 +7382,12 @@ const deserializeAws_queryFailoverGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7332,8 +7419,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -7352,10 +7438,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7387,18 +7475,19 @@ const deserializeAws_queryModifyCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CertificateNotFoundFault": case "com.amazonaws.rds#CertificateNotFoundFault": throw await deserializeAws_queryCertificateNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7430,8 +7519,7 @@ const deserializeAws_queryModifyCurrentDBClusterCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -7444,10 +7532,12 @@ const deserializeAws_queryModifyCurrentDBClusterCapacityCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7479,8 +7569,7 @@ const deserializeAws_queryModifyCustomDBEngineVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomDBEngineVersionNotFoundFault": case "com.amazonaws.rds#CustomDBEngineVersionNotFoundFault": @@ -7490,10 +7579,12 @@ const deserializeAws_queryModifyCustomDBEngineVersionCommandError = async ( throw await deserializeAws_queryInvalidCustomDBEngineVersionStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7525,8 +7616,7 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.rds#DBClusterAlreadyExistsFault": @@ -7566,10 +7656,12 @@ const deserializeAws_queryModifyDBClusterCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7601,8 +7693,7 @@ const deserializeAws_queryModifyDBClusterEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterEndpointNotFoundFault": case "com.amazonaws.rds#DBClusterEndpointNotFoundFault": @@ -7621,10 +7712,12 @@ const deserializeAws_queryModifyDBClusterEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7656,8 +7749,7 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -7667,10 +7759,12 @@ const deserializeAws_queryModifyDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7705,8 +7799,7 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.rds#DBClusterSnapshotNotFoundFault": @@ -7719,10 +7812,12 @@ const deserializeAws_queryModifyDBClusterSnapshotAttributeCommandError = async ( throw await deserializeAws_querySharedSnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7754,8 +7849,7 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -7819,10 +7913,12 @@ const deserializeAws_queryModifyDBInstanceCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7854,8 +7950,7 @@ const deserializeAws_queryModifyDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -7865,10 +7960,12 @@ const deserializeAws_queryModifyDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7900,8 +7997,7 @@ const deserializeAws_queryModifyDBProxyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyAlreadyExistsFault": case "com.amazonaws.rds#DBProxyAlreadyExistsFault": @@ -7914,10 +8010,12 @@ const deserializeAws_queryModifyDBProxyCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7949,8 +8047,7 @@ const deserializeAws_queryModifyDBProxyEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyEndpointAlreadyExistsFault": case "com.amazonaws.rds#DBProxyEndpointAlreadyExistsFault": @@ -7966,10 +8063,12 @@ const deserializeAws_queryModifyDBProxyEndpointCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8001,8 +8100,7 @@ const deserializeAws_queryModifyDBProxyTargetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBProxyNotFoundFault": case "com.amazonaws.rds#DBProxyNotFoundFault": @@ -8015,10 +8113,12 @@ const deserializeAws_queryModifyDBProxyTargetGroupCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8050,18 +8150,19 @@ const deserializeAws_queryModifyDBSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSnapshotNotFoundFault": case "com.amazonaws.rds#DBSnapshotNotFoundFault": throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8093,8 +8194,7 @@ const deserializeAws_queryModifyDBSnapshotAttributeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSnapshotNotFoundFault": case "com.amazonaws.rds#DBSnapshotNotFoundFault": @@ -8107,10 +8207,12 @@ const deserializeAws_queryModifyDBSnapshotAttributeCommandError = async ( throw await deserializeAws_querySharedSnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8142,8 +8244,7 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBSubnetGroupDoesNotCoverEnoughAZs": case "com.amazonaws.rds#DBSubnetGroupDoesNotCoverEnoughAZs": @@ -8162,10 +8263,12 @@ const deserializeAws_queryModifyDBSubnetGroupCommandError = async ( throw await deserializeAws_querySubnetAlreadyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8197,8 +8300,7 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.rds#EventSubscriptionQuotaExceededFault": @@ -8220,10 +8322,12 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8255,8 +8359,7 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "GlobalClusterNotFoundFault": case "com.amazonaws.rds#GlobalClusterNotFoundFault": @@ -8272,10 +8375,12 @@ const deserializeAws_queryModifyGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8307,8 +8412,7 @@ const deserializeAws_queryModifyOptionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOptionGroupStateFault": case "com.amazonaws.rds#InvalidOptionGroupStateFault": @@ -8318,10 +8422,12 @@ const deserializeAws_queryModifyOptionGroupCommandError = async ( throw await deserializeAws_queryOptionGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8353,8 +8459,7 @@ const deserializeAws_queryPromoteReadReplicaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -8364,10 +8469,12 @@ const deserializeAws_queryPromoteReadReplicaCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8399,8 +8506,7 @@ const deserializeAws_queryPromoteReadReplicaDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8410,10 +8516,12 @@ const deserializeAws_queryPromoteReadReplicaDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8448,8 +8556,7 @@ const deserializeAws_queryPurchaseReservedDBInstancesOfferingCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReservedDBInstanceAlreadyExistsFault": case "com.amazonaws.rds#ReservedDBInstanceAlreadyExistsFault": @@ -8462,10 +8569,12 @@ const deserializeAws_queryPurchaseReservedDBInstancesOfferingCommandError = asyn throw await deserializeAws_queryReservedDBInstancesOfferingNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8497,8 +8606,7 @@ const deserializeAws_queryRebootDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8511,10 +8619,12 @@ const deserializeAws_queryRebootDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8546,8 +8656,7 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -8557,10 +8666,12 @@ const deserializeAws_queryRebootDBInstanceCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8592,8 +8703,7 @@ const deserializeAws_queryRegisterDBProxyTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8624,10 +8734,12 @@ const deserializeAws_queryRegisterDBProxyTargetsCommandError = async ( throw await deserializeAws_queryInvalidDBProxyStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8659,8 +8771,7 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8673,10 +8784,12 @@ const deserializeAws_queryRemoveFromGlobalClusterCommandError = async ( throw await deserializeAws_queryInvalidGlobalClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8705,8 +8818,7 @@ const deserializeAws_queryRemoveRoleFromDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8719,10 +8831,12 @@ const deserializeAws_queryRemoveRoleFromDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8751,8 +8865,7 @@ const deserializeAws_queryRemoveRoleFromDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -8765,10 +8878,12 @@ const deserializeAws_queryRemoveRoleFromDBInstanceCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8803,8 +8918,7 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "SourceNotFoundFault": case "com.amazonaws.rds#SourceNotFoundFault": @@ -8814,10 +8928,12 @@ const deserializeAws_queryRemoveSourceIdentifierFromSubscriptionCommandError = a throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8846,8 +8962,7 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -8866,10 +8981,12 @@ const deserializeAws_queryRemoveTagsFromResourceCommandError = async ( throw await deserializeAws_queryDBSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8901,8 +9018,7 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -8912,10 +9028,12 @@ const deserializeAws_queryResetDBClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8947,8 +9065,7 @@ const deserializeAws_queryResetDBParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBParameterGroupNotFoundFault": case "com.amazonaws.rds#DBParameterGroupNotFoundFault": @@ -8958,10 +9075,12 @@ const deserializeAws_queryResetDBParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidDBParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8993,8 +9112,7 @@ const deserializeAws_queryRestoreDBClusterFromS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.rds#DBClusterAlreadyExistsFault": @@ -9040,10 +9158,12 @@ const deserializeAws_queryRestoreDBClusterFromS3CommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9075,8 +9195,7 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.rds#DBClusterAlreadyExistsFault": @@ -9131,10 +9250,12 @@ const deserializeAws_queryRestoreDBClusterFromSnapshotCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9166,8 +9287,7 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterAlreadyExistsFault": case "com.amazonaws.rds#DBClusterAlreadyExistsFault": @@ -9225,10 +9345,12 @@ const deserializeAws_queryRestoreDBClusterToPointInTimeCommandError = async ( throw await deserializeAws_queryStorageQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9263,8 +9385,7 @@ const deserializeAws_queryRestoreDBInstanceFromDBSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -9331,10 +9452,12 @@ const deserializeAws_queryRestoreDBInstanceFromDBSnapshotCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9366,8 +9489,7 @@ const deserializeAws_queryRestoreDBInstanceFromS3CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -9425,10 +9547,12 @@ const deserializeAws_queryRestoreDBInstanceFromS3CommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9463,8 +9587,7 @@ const deserializeAws_queryRestoreDBInstanceToPointInTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -9537,10 +9660,12 @@ const deserializeAws_queryRestoreDBInstanceToPointInTimeCommandError = async ( throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9572,8 +9697,7 @@ const deserializeAws_queryRevokeDBSecurityGroupIngressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -9586,10 +9710,12 @@ const deserializeAws_queryRevokeDBSecurityGroupIngressCommandError = async ( throw await deserializeAws_queryInvalidDBSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9621,8 +9747,7 @@ const deserializeAws_queryStartActivityStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -9644,10 +9769,12 @@ const deserializeAws_queryStartActivityStreamCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9679,8 +9806,7 @@ const deserializeAws_queryStartDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -9693,10 +9819,12 @@ const deserializeAws_queryStartDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9728,8 +9856,7 @@ const deserializeAws_queryStartDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.rds#AuthorizationNotFoundFault": @@ -9766,10 +9893,12 @@ const deserializeAws_queryStartDBInstanceCommandError = async ( throw await deserializeAws_queryKMSKeyNotAccessibleFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9804,8 +9933,7 @@ const deserializeAws_queryStartDBInstanceAutomatedBackupsReplicationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceAutomatedBackupQuotaExceededFault": case "com.amazonaws.rds#DBInstanceAutomatedBackupQuotaExceededFault": @@ -9824,10 +9952,12 @@ const deserializeAws_queryStartDBInstanceAutomatedBackupsReplicationCommandError throw await deserializeAws_queryStorageTypeNotSupportedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9859,8 +9989,7 @@ const deserializeAws_queryStartExportTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterSnapshotNotFoundFault": case "com.amazonaws.rds#DBClusterSnapshotNotFoundFault": @@ -9891,10 +10020,12 @@ const deserializeAws_queryStartExportTaskCommandError = async ( throw await deserializeAws_queryKMSKeyNotAccessibleFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9926,8 +10057,7 @@ const deserializeAws_queryStopActivityStreamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -9946,10 +10076,12 @@ const deserializeAws_queryStopActivityStreamCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9981,8 +10113,7 @@ const deserializeAws_queryStopDBClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBClusterNotFoundFault": case "com.amazonaws.rds#DBClusterNotFoundFault": @@ -9995,10 +10126,12 @@ const deserializeAws_queryStopDBClusterCommandError = async ( throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10030,8 +10163,7 @@ const deserializeAws_queryStopDBInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -10050,10 +10182,12 @@ const deserializeAws_queryStopDBInstanceCommandError = async ( throw await deserializeAws_querySnapshotQuotaExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -10088,8 +10222,7 @@ const deserializeAws_queryStopDBInstanceAutomatedBackupsReplicationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DBInstanceNotFoundFault": case "com.amazonaws.rds#DBInstanceNotFoundFault": @@ -10099,10 +10232,12 @@ const deserializeAws_queryStopDBInstanceAutomatedBackupsReplicationCommandError throw await deserializeAws_queryInvalidDBInstanceStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -24449,12 +24584,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-redshift-data/src/protocols/Aws_json1_1.ts b/clients/client-redshift-data/src/protocols/Aws_json1_1.ts index 2a2f8904d960f..d603bd2528713 100644 --- a/clients/client-redshift-data/src/protocols/Aws_json1_1.ts +++ b/clients/client-redshift-data/src/protocols/Aws_json1_1.ts @@ -225,8 +225,7 @@ const deserializeAws_json1_1BatchExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveStatementsExceededException": case "com.amazonaws.redshiftdata#ActiveStatementsExceededException": @@ -239,10 +238,12 @@ const deserializeAws_json1_1BatchExecuteStatementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -274,8 +275,7 @@ const deserializeAws_json1_1CancelStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DatabaseConnectionException": case "com.amazonaws.redshiftdata#DatabaseConnectionException": @@ -291,10 +291,12 @@ const deserializeAws_json1_1CancelStatementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -326,8 +328,7 @@ const deserializeAws_json1_1DescribeStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.redshiftdata#InternalServerException": @@ -340,10 +341,12 @@ const deserializeAws_json1_1DescribeStatementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -375,8 +378,7 @@ const deserializeAws_json1_1DescribeTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DatabaseConnectionException": case "com.amazonaws.redshiftdata#DatabaseConnectionException": @@ -389,10 +391,12 @@ const deserializeAws_json1_1DescribeTableCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -424,8 +428,7 @@ const deserializeAws_json1_1ExecuteStatementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActiveStatementsExceededException": case "com.amazonaws.redshiftdata#ActiveStatementsExceededException": @@ -438,10 +441,12 @@ const deserializeAws_json1_1ExecuteStatementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -473,8 +478,7 @@ const deserializeAws_json1_1GetStatementResultCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.redshiftdata#InternalServerException": @@ -487,10 +491,12 @@ const deserializeAws_json1_1GetStatementResultCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -522,8 +528,7 @@ const deserializeAws_json1_1ListDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DatabaseConnectionException": case "com.amazonaws.redshiftdata#DatabaseConnectionException": @@ -536,10 +541,12 @@ const deserializeAws_json1_1ListDatabasesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -571,8 +578,7 @@ const deserializeAws_json1_1ListSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DatabaseConnectionException": case "com.amazonaws.redshiftdata#DatabaseConnectionException": @@ -585,10 +591,12 @@ const deserializeAws_json1_1ListSchemasCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -620,8 +628,7 @@ const deserializeAws_json1_1ListStatementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.redshiftdata#InternalServerException": @@ -631,10 +638,12 @@ const deserializeAws_json1_1ListStatementsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -666,8 +675,7 @@ const deserializeAws_json1_1ListTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DatabaseConnectionException": case "com.amazonaws.redshiftdata#DatabaseConnectionException": @@ -680,10 +688,12 @@ const deserializeAws_json1_1ListTablesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1446,7 +1456,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1472,6 +1482,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-redshift/src/protocols/Aws_query.ts b/clients/client-redshift/src/protocols/Aws_query.ts index b0523b4a51929..53c0b8a78301e 100644 --- a/clients/client-redshift/src/protocols/Aws_query.ts +++ b/clients/client-redshift/src/protocols/Aws_query.ts @@ -2752,8 +2752,7 @@ const deserializeAws_queryAcceptReservedNodeExchangeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependentServiceUnavailableFault": case "com.amazonaws.redshift#DependentServiceUnavailableFault": @@ -2778,10 +2777,12 @@ const deserializeAws_queryAcceptReservedNodeExchangeCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2813,8 +2814,7 @@ const deserializeAws_queryAddPartnerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -2827,10 +2827,12 @@ const deserializeAws_queryAddPartnerCommandError = async ( throw await deserializeAws_queryUnauthorizedPartnerIntegrationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2862,8 +2864,7 @@ const deserializeAws_queryAssociateDataShareConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": @@ -2873,10 +2874,12 @@ const deserializeAws_queryAssociateDataShareConsumerCommandError = async ( throw await deserializeAws_queryInvalidNamespaceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2911,8 +2914,7 @@ const deserializeAws_queryAuthorizeClusterSecurityGroupIngressCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationAlreadyExistsFault": case "com.amazonaws.redshift#AuthorizationAlreadyExistsFault": @@ -2928,10 +2930,12 @@ const deserializeAws_queryAuthorizeClusterSecurityGroupIngressCommandError = asy throw await deserializeAws_queryInvalidClusterSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2963,18 +2967,19 @@ const deserializeAws_queryAuthorizeDataShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": throw await deserializeAws_queryInvalidDataShareFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3006,8 +3011,7 @@ const deserializeAws_queryAuthorizeEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -3029,10 +3033,12 @@ const deserializeAws_queryAuthorizeEndpointAccessCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3064,8 +3070,7 @@ const deserializeAws_queryAuthorizeSnapshotAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationAlreadyExistsFault": case "com.amazonaws.redshift#AuthorizationAlreadyExistsFault": @@ -3087,10 +3092,12 @@ const deserializeAws_queryAuthorizeSnapshotAccessCommandError = async ( throw await deserializeAws_queryLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3122,18 +3129,19 @@ const deserializeAws_queryBatchDeleteClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchDeleteRequestSizeExceededFault": case "com.amazonaws.redshift#BatchDeleteRequestSizeExceededFault": throw await deserializeAws_queryBatchDeleteRequestSizeExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3168,8 +3176,7 @@ const deserializeAws_queryBatchModifyClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchModifyClusterSnapshotsLimitExceededFault": case "com.amazonaws.redshift#BatchModifyClusterSnapshotsLimitExceededFault": @@ -3179,10 +3186,12 @@ const deserializeAws_queryBatchModifyClusterSnapshotsCommandError = async ( throw await deserializeAws_queryInvalidRetentionPeriodFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3214,8 +3223,7 @@ const deserializeAws_queryCancelResizeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -3231,10 +3239,12 @@ const deserializeAws_queryCancelResizeCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3266,8 +3276,7 @@ const deserializeAws_queryCopyClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSnapshotAlreadyExistsFault": case "com.amazonaws.redshift#ClusterSnapshotAlreadyExistsFault": @@ -3286,10 +3295,12 @@ const deserializeAws_queryCopyClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidRetentionPeriodFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3321,8 +3332,7 @@ const deserializeAws_queryCreateAuthenticationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationProfileAlreadyExistsFault": case "com.amazonaws.redshift#AuthenticationProfileAlreadyExistsFault": @@ -3335,10 +3345,12 @@ const deserializeAws_queryCreateAuthenticationProfileCommandError = async ( throw await deserializeAws_queryInvalidAuthenticationProfileRequestFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3370,8 +3382,7 @@ const deserializeAws_queryCreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterAlreadyExistsFault": case "com.amazonaws.redshift#ClusterAlreadyExistsFault": @@ -3441,10 +3452,12 @@ const deserializeAws_queryCreateClusterCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3476,8 +3489,7 @@ const deserializeAws_queryCreateClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupAlreadyExistsFault": case "com.amazonaws.redshift#ClusterParameterGroupAlreadyExistsFault": @@ -3493,10 +3505,12 @@ const deserializeAws_queryCreateClusterParameterGroupCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3528,8 +3542,7 @@ const deserializeAws_queryCreateClusterSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSecurityGroupAlreadyExistsFault": case "com.amazonaws.redshift#ClusterSecurityGroupAlreadyExistsFault": @@ -3545,10 +3558,12 @@ const deserializeAws_queryCreateClusterSecurityGroupCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3580,8 +3595,7 @@ const deserializeAws_queryCreateClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -3606,10 +3620,12 @@ const deserializeAws_queryCreateClusterSnapshotCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3641,8 +3657,7 @@ const deserializeAws_queryCreateClusterSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSubnetGroupAlreadyExistsFault": case "com.amazonaws.redshift#ClusterSubnetGroupAlreadyExistsFault": @@ -3670,10 +3685,12 @@ const deserializeAws_queryCreateClusterSubnetGroupCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3705,8 +3722,7 @@ const deserializeAws_queryCreateEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessToClusterDeniedFault": case "com.amazonaws.redshift#AccessToClusterDeniedFault": @@ -3740,10 +3756,12 @@ const deserializeAws_queryCreateEndpointAccessCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3775,8 +3793,7 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "EventSubscriptionQuotaExceededFault": case "com.amazonaws.redshift#EventSubscriptionQuotaExceededFault": @@ -3813,10 +3830,12 @@ const deserializeAws_queryCreateEventSubscriptionCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3848,8 +3867,7 @@ const deserializeAws_queryCreateHsmClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmClientCertificateAlreadyExistsFault": case "com.amazonaws.redshift#HsmClientCertificateAlreadyExistsFault": @@ -3865,10 +3883,12 @@ const deserializeAws_queryCreateHsmClientCertificateCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3900,8 +3920,7 @@ const deserializeAws_queryCreateHsmConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmConfigurationAlreadyExistsFault": case "com.amazonaws.redshift#HsmConfigurationAlreadyExistsFault": @@ -3917,10 +3936,12 @@ const deserializeAws_queryCreateHsmConfigurationCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3952,8 +3973,7 @@ const deserializeAws_queryCreateScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidScheduledActionFault": case "com.amazonaws.redshift#InvalidScheduledActionFault": @@ -3975,10 +3995,12 @@ const deserializeAws_queryCreateScheduledActionCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4010,8 +4032,7 @@ const deserializeAws_queryCreateSnapshotCopyGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependentServiceRequestThrottlingFault": case "com.amazonaws.redshift#DependentServiceRequestThrottlingFault": @@ -4033,10 +4054,12 @@ const deserializeAws_queryCreateSnapshotCopyGrantCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4068,8 +4091,7 @@ const deserializeAws_queryCreateSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidScheduleFault": case "com.amazonaws.redshift#InvalidScheduleFault": @@ -4091,10 +4113,12 @@ const deserializeAws_queryCreateSnapshotScheduleCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4123,8 +4147,7 @@ const deserializeAws_queryCreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClusterStateFault": case "com.amazonaws.redshift#InvalidClusterStateFault": @@ -4140,10 +4163,12 @@ const deserializeAws_queryCreateTagsCommandError = async ( throw await deserializeAws_queryTagLimitExceededFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4175,8 +4200,7 @@ const deserializeAws_queryCreateUsageLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -4201,10 +4225,12 @@ const deserializeAws_queryCreateUsageLimitCommandError = async ( throw await deserializeAws_queryUsageLimitAlreadyExistsFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4236,18 +4262,19 @@ const deserializeAws_queryDeauthorizeDataShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": throw await deserializeAws_queryInvalidDataShareFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4279,8 +4306,7 @@ const deserializeAws_queryDeleteAuthenticationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationProfileNotFoundFault": case "com.amazonaws.redshift#AuthenticationProfileNotFoundFault": @@ -4290,10 +4316,12 @@ const deserializeAws_queryDeleteAuthenticationProfileCommandError = async ( throw await deserializeAws_queryInvalidAuthenticationProfileRequestFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4325,8 +4353,7 @@ const deserializeAws_queryDeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -4345,10 +4372,12 @@ const deserializeAws_queryDeleteClusterCommandError = async ( throw await deserializeAws_queryInvalidRetentionPeriodFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4377,8 +4406,7 @@ const deserializeAws_queryDeleteClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupNotFoundFault": case "com.amazonaws.redshift#ClusterParameterGroupNotFoundFault": @@ -4388,10 +4416,12 @@ const deserializeAws_queryDeleteClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidClusterParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4420,8 +4450,7 @@ const deserializeAws_queryDeleteClusterSecurityGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSecurityGroupNotFoundFault": case "com.amazonaws.redshift#ClusterSecurityGroupNotFoundFault": @@ -4431,10 +4460,12 @@ const deserializeAws_queryDeleteClusterSecurityGroupCommandError = async ( throw await deserializeAws_queryInvalidClusterSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4466,8 +4497,7 @@ const deserializeAws_queryDeleteClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSnapshotNotFoundFault": case "com.amazonaws.redshift#ClusterSnapshotNotFoundFault": @@ -4477,10 +4507,12 @@ const deserializeAws_queryDeleteClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidClusterSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4509,8 +4541,7 @@ const deserializeAws_queryDeleteClusterSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSubnetGroupNotFoundFault": case "com.amazonaws.redshift#ClusterSubnetGroupNotFoundFault": @@ -4523,10 +4554,12 @@ const deserializeAws_queryDeleteClusterSubnetGroupCommandError = async ( throw await deserializeAws_queryInvalidClusterSubnetStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4558,8 +4591,7 @@ const deserializeAws_queryDeleteEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -4578,10 +4610,12 @@ const deserializeAws_queryDeleteEndpointAccessCommandError = async ( throw await deserializeAws_queryInvalidEndpointStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4610,8 +4644,7 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubscriptionStateFault": case "com.amazonaws.redshift#InvalidSubscriptionStateFault": @@ -4621,10 +4654,12 @@ const deserializeAws_queryDeleteEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4653,8 +4688,7 @@ const deserializeAws_queryDeleteHsmClientCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmClientCertificateNotFoundFault": case "com.amazonaws.redshift#HsmClientCertificateNotFoundFault": @@ -4664,10 +4698,12 @@ const deserializeAws_queryDeleteHsmClientCertificateCommandError = async ( throw await deserializeAws_queryInvalidHsmClientCertificateStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4696,8 +4732,7 @@ const deserializeAws_queryDeleteHsmConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmConfigurationNotFoundFault": case "com.amazonaws.redshift#HsmConfigurationNotFoundFault": @@ -4707,10 +4742,12 @@ const deserializeAws_queryDeleteHsmConfigurationCommandError = async ( throw await deserializeAws_queryInvalidHsmConfigurationStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4742,8 +4779,7 @@ const deserializeAws_queryDeletePartnerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -4756,10 +4792,12 @@ const deserializeAws_queryDeletePartnerCommandError = async ( throw await deserializeAws_queryUnauthorizedPartnerIntegrationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4788,8 +4826,7 @@ const deserializeAws_queryDeleteScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ScheduledActionNotFoundFault": case "com.amazonaws.redshift#ScheduledActionNotFoundFault": @@ -4799,10 +4836,12 @@ const deserializeAws_queryDeleteScheduledActionCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4831,8 +4870,7 @@ const deserializeAws_queryDeleteSnapshotCopyGrantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSnapshotCopyGrantStateFault": case "com.amazonaws.redshift#InvalidSnapshotCopyGrantStateFault": @@ -4842,10 +4880,12 @@ const deserializeAws_queryDeleteSnapshotCopyGrantCommandError = async ( throw await deserializeAws_querySnapshotCopyGrantNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4874,8 +4914,7 @@ const deserializeAws_queryDeleteSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClusterSnapshotScheduleStateFault": case "com.amazonaws.redshift#InvalidClusterSnapshotScheduleStateFault": @@ -4885,10 +4924,12 @@ const deserializeAws_queryDeleteSnapshotScheduleCommandError = async ( throw await deserializeAws_querySnapshotScheduleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4917,8 +4958,7 @@ const deserializeAws_queryDeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTagFault": case "com.amazonaws.redshift#InvalidTagFault": @@ -4928,10 +4968,12 @@ const deserializeAws_queryDeleteTagsCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4960,8 +5002,7 @@ const deserializeAws_queryDeleteUsageLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "UnsupportedOperationFault": case "com.amazonaws.redshift#UnsupportedOperationFault": @@ -4971,10 +5012,12 @@ const deserializeAws_queryDeleteUsageLimitCommandError = async ( throw await deserializeAws_queryUsageLimitNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5006,15 +5049,16 @@ const deserializeAws_queryDescribeAccountAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5049,8 +5093,7 @@ const deserializeAws_queryDescribeAuthenticationProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationProfileNotFoundFault": case "com.amazonaws.redshift#AuthenticationProfileNotFoundFault": @@ -5060,10 +5103,12 @@ const deserializeAws_queryDescribeAuthenticationProfilesCommandError = async ( throw await deserializeAws_queryInvalidAuthenticationProfileRequestFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5095,8 +5140,7 @@ const deserializeAws_queryDescribeClusterDbRevisionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -5106,10 +5150,12 @@ const deserializeAws_queryDescribeClusterDbRevisionsCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5141,8 +5187,7 @@ const deserializeAws_queryDescribeClusterParameterGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupNotFoundFault": case "com.amazonaws.redshift#ClusterParameterGroupNotFoundFault": @@ -5152,10 +5197,12 @@ const deserializeAws_queryDescribeClusterParameterGroupsCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5187,18 +5234,19 @@ const deserializeAws_queryDescribeClusterParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupNotFoundFault": case "com.amazonaws.redshift#ClusterParameterGroupNotFoundFault": throw await deserializeAws_queryClusterParameterGroupNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5230,8 +5278,7 @@ const deserializeAws_queryDescribeClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -5241,10 +5288,12 @@ const deserializeAws_queryDescribeClustersCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5276,8 +5325,7 @@ const deserializeAws_queryDescribeClusterSecurityGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSecurityGroupNotFoundFault": case "com.amazonaws.redshift#ClusterSecurityGroupNotFoundFault": @@ -5287,10 +5335,12 @@ const deserializeAws_queryDescribeClusterSecurityGroupsCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5322,8 +5372,7 @@ const deserializeAws_queryDescribeClusterSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -5336,10 +5385,12 @@ const deserializeAws_queryDescribeClusterSnapshotsCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5371,8 +5422,7 @@ const deserializeAws_queryDescribeClusterSubnetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSubnetGroupNotFoundFault": case "com.amazonaws.redshift#ClusterSubnetGroupNotFoundFault": @@ -5382,10 +5432,12 @@ const deserializeAws_queryDescribeClusterSubnetGroupsCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5417,8 +5469,7 @@ const deserializeAws_queryDescribeClusterTracksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidClusterTrackFault": case "com.amazonaws.redshift#InvalidClusterTrackFault": @@ -5428,10 +5479,12 @@ const deserializeAws_queryDescribeClusterTracksCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5463,15 +5516,16 @@ const deserializeAws_queryDescribeClusterVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5503,18 +5557,19 @@ const deserializeAws_queryDescribeDataSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": throw await deserializeAws_queryInvalidDataShareFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5546,18 +5601,19 @@ const deserializeAws_queryDescribeDataSharesForConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNamespaceFault": case "com.amazonaws.redshift#InvalidNamespaceFault": throw await deserializeAws_queryInvalidNamespaceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5589,18 +5645,19 @@ const deserializeAws_queryDescribeDataSharesForProducerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNamespaceFault": case "com.amazonaws.redshift#InvalidNamespaceFault": throw await deserializeAws_queryInvalidNamespaceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5635,15 +5692,16 @@ const deserializeAws_queryDescribeDefaultClusterParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5675,8 +5733,7 @@ const deserializeAws_queryDescribeEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -5689,10 +5746,12 @@ const deserializeAws_queryDescribeEndpointAccessCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5724,8 +5783,7 @@ const deserializeAws_queryDescribeEndpointAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -5735,10 +5793,12 @@ const deserializeAws_queryDescribeEndpointAuthorizationCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5770,15 +5830,16 @@ const deserializeAws_queryDescribeEventCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5810,15 +5871,16 @@ const deserializeAws_queryDescribeEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5850,8 +5912,7 @@ const deserializeAws_queryDescribeEventSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTagFault": case "com.amazonaws.redshift#InvalidTagFault": @@ -5861,10 +5922,12 @@ const deserializeAws_queryDescribeEventSubscriptionsCommandError = async ( throw await deserializeAws_querySubscriptionNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5896,8 +5959,7 @@ const deserializeAws_queryDescribeHsmClientCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmClientCertificateNotFoundFault": case "com.amazonaws.redshift#HsmClientCertificateNotFoundFault": @@ -5907,10 +5969,12 @@ const deserializeAws_queryDescribeHsmClientCertificatesCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5942,8 +6006,7 @@ const deserializeAws_queryDescribeHsmConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "HsmConfigurationNotFoundFault": case "com.amazonaws.redshift#HsmConfigurationNotFoundFault": @@ -5953,10 +6016,12 @@ const deserializeAws_queryDescribeHsmConfigurationsCommandError = async ( throw await deserializeAws_queryInvalidTagFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5988,18 +6053,19 @@ const deserializeAws_queryDescribeLoggingStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": throw await deserializeAws_queryClusterNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6031,8 +6097,7 @@ const deserializeAws_queryDescribeNodeConfigurationOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessToSnapshotDeniedFault": case "com.amazonaws.redshift#AccessToSnapshotDeniedFault": @@ -6048,10 +6113,12 @@ const deserializeAws_queryDescribeNodeConfigurationOptionsCommandError = async ( throw await deserializeAws_queryInvalidClusterSnapshotStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6083,15 +6150,16 @@ const deserializeAws_queryDescribeOrderableClusterOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6123,8 +6191,7 @@ const deserializeAws_queryDescribePartnersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6134,10 +6201,12 @@ const deserializeAws_queryDescribePartnersCommandError = async ( throw await deserializeAws_queryUnauthorizedPartnerIntegrationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6172,8 +6241,7 @@ const deserializeAws_queryDescribeReservedNodeExchangeStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReservedNodeExchangeNotFoundFault": case "com.amazonaws.redshift#ReservedNodeExchangeNotFoundFault": @@ -6186,10 +6254,12 @@ const deserializeAws_queryDescribeReservedNodeExchangeStatusCommandError = async throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6221,8 +6291,7 @@ const deserializeAws_queryDescribeReservedNodeOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependentServiceUnavailableFault": case "com.amazonaws.redshift#DependentServiceUnavailableFault": @@ -6235,10 +6304,12 @@ const deserializeAws_queryDescribeReservedNodeOfferingsCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6270,8 +6341,7 @@ const deserializeAws_queryDescribeReservedNodesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependentServiceUnavailableFault": case "com.amazonaws.redshift#DependentServiceUnavailableFault": @@ -6281,10 +6351,12 @@ const deserializeAws_queryDescribeReservedNodesCommandError = async ( throw await deserializeAws_queryReservedNodeNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6316,8 +6388,7 @@ const deserializeAws_queryDescribeResizeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6327,10 +6398,12 @@ const deserializeAws_queryDescribeResizeCommandError = async ( throw await deserializeAws_queryResizeNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6362,8 +6435,7 @@ const deserializeAws_queryDescribeScheduledActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ScheduledActionNotFoundFault": case "com.amazonaws.redshift#ScheduledActionNotFoundFault": @@ -6373,10 +6445,12 @@ const deserializeAws_queryDescribeScheduledActionsCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6408,8 +6482,7 @@ const deserializeAws_queryDescribeSnapshotCopyGrantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTagFault": case "com.amazonaws.redshift#InvalidTagFault": @@ -6419,10 +6492,12 @@ const deserializeAws_queryDescribeSnapshotCopyGrantsCommandError = async ( throw await deserializeAws_querySnapshotCopyGrantNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6454,15 +6529,16 @@ const deserializeAws_queryDescribeSnapshotSchedulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6494,15 +6570,16 @@ const deserializeAws_queryDescribeStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6534,8 +6611,7 @@ const deserializeAws_queryDescribeTableRestoreStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6545,10 +6621,12 @@ const deserializeAws_queryDescribeTableRestoreStatusCommandError = async ( throw await deserializeAws_queryTableRestoreNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6580,8 +6658,7 @@ const deserializeAws_queryDescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTagFault": case "com.amazonaws.redshift#InvalidTagFault": @@ -6591,10 +6668,12 @@ const deserializeAws_queryDescribeTagsCommandError = async ( throw await deserializeAws_queryResourceNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6626,8 +6705,7 @@ const deserializeAws_queryDescribeUsageLimitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6637,10 +6715,12 @@ const deserializeAws_queryDescribeUsageLimitsCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6672,8 +6752,7 @@ const deserializeAws_queryDisableLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6683,10 +6762,12 @@ const deserializeAws_queryDisableLoggingCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6718,8 +6799,7 @@ const deserializeAws_queryDisableSnapshotCopyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6735,10 +6815,12 @@ const deserializeAws_queryDisableSnapshotCopyCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6770,8 +6852,7 @@ const deserializeAws_queryDisassociateDataShareConsumerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": @@ -6781,10 +6862,12 @@ const deserializeAws_queryDisassociateDataShareConsumerCommandError = async ( throw await deserializeAws_queryInvalidNamespaceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6816,8 +6899,7 @@ const deserializeAws_queryEnableLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BucketNotFoundFault": case "com.amazonaws.redshift#BucketNotFoundFault": @@ -6839,10 +6921,12 @@ const deserializeAws_queryEnableLoggingCommandError = async ( throw await deserializeAws_queryInvalidS3KeyPrefixFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6874,8 +6958,7 @@ const deserializeAws_queryEnableSnapshotCopyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6912,10 +6995,12 @@ const deserializeAws_queryEnableSnapshotCopyCommandError = async ( throw await deserializeAws_queryUnknownSnapshotCopyRegionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6947,8 +7032,7 @@ const deserializeAws_queryGetClusterCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -6958,10 +7042,12 @@ const deserializeAws_queryGetClusterCredentialsCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6993,8 +7079,7 @@ const deserializeAws_queryGetClusterCredentialsWithIAMCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7004,10 +7089,12 @@ const deserializeAws_queryGetClusterCredentialsWithIAMCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7042,8 +7129,7 @@ const deserializeAws_queryGetReservedNodeExchangeConfigurationOptionsCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7071,10 +7157,12 @@ const deserializeAws_queryGetReservedNodeExchangeConfigurationOptionsCommandErro throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7109,8 +7197,7 @@ const deserializeAws_queryGetReservedNodeExchangeOfferingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "DependentServiceUnavailableFault": case "com.amazonaws.redshift#DependentServiceUnavailableFault": @@ -7132,10 +7219,12 @@ const deserializeAws_queryGetReservedNodeExchangeOfferingsCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7167,8 +7256,7 @@ const deserializeAws_queryModifyAquaConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7181,10 +7269,12 @@ const deserializeAws_queryModifyAquaConfigurationCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7216,8 +7306,7 @@ const deserializeAws_queryModifyAuthenticationProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthenticationProfileNotFoundFault": case "com.amazonaws.redshift#AuthenticationProfileNotFoundFault": @@ -7230,10 +7319,12 @@ const deserializeAws_queryModifyAuthenticationProfileCommandError = async ( throw await deserializeAws_queryInvalidAuthenticationProfileRequestFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7265,8 +7356,7 @@ const deserializeAws_queryModifyClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterAlreadyExistsFault": case "com.amazonaws.redshift#ClusterAlreadyExistsFault": @@ -7327,10 +7417,12 @@ const deserializeAws_queryModifyClusterCommandError = async ( throw await deserializeAws_queryUnsupportedOptionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7362,8 +7454,7 @@ const deserializeAws_queryModifyClusterDbRevisionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7376,10 +7467,12 @@ const deserializeAws_queryModifyClusterDbRevisionCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7411,8 +7504,7 @@ const deserializeAws_queryModifyClusterIamRolesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7422,10 +7514,12 @@ const deserializeAws_queryModifyClusterIamRolesCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7457,8 +7551,7 @@ const deserializeAws_queryModifyClusterMaintenanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7468,10 +7561,12 @@ const deserializeAws_queryModifyClusterMaintenanceCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7503,8 +7598,7 @@ const deserializeAws_queryModifyClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupNotFoundFault": case "com.amazonaws.redshift#ClusterParameterGroupNotFoundFault": @@ -7514,10 +7608,12 @@ const deserializeAws_queryModifyClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidClusterParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7549,8 +7645,7 @@ const deserializeAws_queryModifyClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSnapshotNotFoundFault": case "com.amazonaws.redshift#ClusterSnapshotNotFoundFault": @@ -7563,10 +7658,12 @@ const deserializeAws_queryModifyClusterSnapshotCommandError = async ( throw await deserializeAws_queryInvalidRetentionPeriodFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7595,8 +7692,7 @@ const deserializeAws_queryModifyClusterSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7609,10 +7705,12 @@ const deserializeAws_queryModifyClusterSnapshotScheduleCommandError = async ( throw await deserializeAws_querySnapshotScheduleNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7644,8 +7742,7 @@ const deserializeAws_queryModifyClusterSubnetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterSubnetGroupNotFoundFault": case "com.amazonaws.redshift#ClusterSubnetGroupNotFoundFault": @@ -7667,10 +7764,12 @@ const deserializeAws_queryModifyClusterSubnetGroupCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7702,8 +7801,7 @@ const deserializeAws_queryModifyEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7725,10 +7823,12 @@ const deserializeAws_queryModifyEndpointAccessCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7760,8 +7860,7 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidSubscriptionStateFault": case "com.amazonaws.redshift#InvalidSubscriptionStateFault": @@ -7792,10 +7891,12 @@ const deserializeAws_queryModifyEventSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionSeverityNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7827,8 +7928,7 @@ const deserializeAws_queryModifyScheduledActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidScheduledActionFault": case "com.amazonaws.redshift#InvalidScheduledActionFault": @@ -7847,10 +7947,12 @@ const deserializeAws_queryModifyScheduledActionCommandError = async ( throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7885,8 +7987,7 @@ const deserializeAws_queryModifySnapshotCopyRetentionPeriodCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -7905,10 +8006,12 @@ const deserializeAws_queryModifySnapshotCopyRetentionPeriodCommandError = async throw await deserializeAws_queryUnauthorizedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7940,8 +8043,7 @@ const deserializeAws_queryModifySnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidScheduleFault": case "com.amazonaws.redshift#InvalidScheduleFault": @@ -7954,10 +8056,12 @@ const deserializeAws_queryModifySnapshotScheduleCommandError = async ( throw await deserializeAws_querySnapshotScheduleUpdateInProgressFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -7989,8 +8093,7 @@ const deserializeAws_queryModifyUsageLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidUsageLimitFault": case "com.amazonaws.redshift#InvalidUsageLimitFault": @@ -8003,10 +8106,12 @@ const deserializeAws_queryModifyUsageLimitCommandError = async ( throw await deserializeAws_queryUsageLimitNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8038,8 +8143,7 @@ const deserializeAws_queryPauseClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8049,10 +8153,12 @@ const deserializeAws_queryPauseClusterCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8084,8 +8190,7 @@ const deserializeAws_queryPurchaseReservedNodeOfferingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ReservedNodeAlreadyExistsFault": case "com.amazonaws.redshift#ReservedNodeAlreadyExistsFault": @@ -8101,10 +8206,12 @@ const deserializeAws_queryPurchaseReservedNodeOfferingCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8136,8 +8243,7 @@ const deserializeAws_queryRebootClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8147,10 +8253,12 @@ const deserializeAws_queryRebootClusterCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8182,18 +8290,19 @@ const deserializeAws_queryRejectDataShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDataShareFault": case "com.amazonaws.redshift#InvalidDataShareFault": throw await deserializeAws_queryInvalidDataShareFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8225,8 +8334,7 @@ const deserializeAws_queryResetClusterParameterGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterParameterGroupNotFoundFault": case "com.amazonaws.redshift#ClusterParameterGroupNotFoundFault": @@ -8236,10 +8344,12 @@ const deserializeAws_queryResetClusterParameterGroupCommandError = async ( throw await deserializeAws_queryInvalidClusterParameterGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8271,8 +8381,7 @@ const deserializeAws_queryResizeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8321,10 +8430,12 @@ const deserializeAws_queryResizeClusterCommandError = async ( throw await deserializeAws_queryUnsupportedOptionFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8356,8 +8467,7 @@ const deserializeAws_queryRestoreFromClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessToSnapshotDeniedFault": case "com.amazonaws.redshift#AccessToSnapshotDeniedFault": @@ -8457,10 +8567,12 @@ const deserializeAws_queryRestoreFromClusterSnapshotCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8495,8 +8607,7 @@ const deserializeAws_queryRestoreTableFromClusterSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8521,10 +8632,12 @@ const deserializeAws_queryRestoreTableFromClusterSnapshotCommandError = async ( throw await deserializeAws_queryUnsupportedOperationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8556,8 +8669,7 @@ const deserializeAws_queryResumeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8570,10 +8682,12 @@ const deserializeAws_queryResumeClusterCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8608,8 +8722,7 @@ const deserializeAws_queryRevokeClusterSecurityGroupIngressCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationNotFoundFault": case "com.amazonaws.redshift#AuthorizationNotFoundFault": @@ -8622,10 +8735,12 @@ const deserializeAws_queryRevokeClusterSecurityGroupIngressCommandError = async throw await deserializeAws_queryInvalidClusterSecurityGroupStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8657,8 +8772,7 @@ const deserializeAws_queryRevokeEndpointAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8683,10 +8797,12 @@ const deserializeAws_queryRevokeEndpointAccessCommandError = async ( throw await deserializeAws_queryInvalidEndpointStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8718,8 +8834,7 @@ const deserializeAws_queryRevokeSnapshotAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessToSnapshotDeniedFault": case "com.amazonaws.redshift#AccessToSnapshotDeniedFault": @@ -8732,10 +8847,12 @@ const deserializeAws_queryRevokeSnapshotAccessCommandError = async ( throw await deserializeAws_queryClusterSnapshotNotFoundFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8767,8 +8884,7 @@ const deserializeAws_queryRotateEncryptionKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8781,10 +8897,12 @@ const deserializeAws_queryRotateEncryptionKeyCommandError = async ( throw await deserializeAws_queryInvalidClusterStateFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -8816,8 +8934,7 @@ const deserializeAws_queryUpdatePartnerStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterNotFoundFault": case "com.amazonaws.redshift#ClusterNotFoundFault": @@ -8830,10 +8947,12 @@ const deserializeAws_queryUpdatePartnerStatusCommandError = async ( throw await deserializeAws_queryUnauthorizedPartnerIntegrationFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -19865,12 +19984,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-rekognition/src/protocols/Aws_json1_1.ts b/clients/client-rekognition/src/protocols/Aws_json1_1.ts index c2e9960abe2d6..d6a99ca9ff852 100644 --- a/clients/client-rekognition/src/protocols/Aws_json1_1.ts +++ b/clients/client-rekognition/src/protocols/Aws_json1_1.ts @@ -1197,8 +1197,7 @@ const deserializeAws_json1_1CompareFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1226,10 +1225,12 @@ const deserializeAws_json1_1CompareFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,8 +1262,7 @@ const deserializeAws_json1_1CreateCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1287,10 +1287,12 @@ const deserializeAws_json1_1CreateCollectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1324,7 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1354,10 +1355,12 @@ const deserializeAws_json1_1CreateDatasetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1389,8 +1392,7 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1415,10 +1417,12 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1450,8 +1454,7 @@ const deserializeAws_json1_1CreateProjectVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1482,10 +1485,12 @@ const deserializeAws_json1_1CreateProjectVersionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1517,8 +1522,7 @@ const deserializeAws_json1_1CreateStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1546,10 +1550,12 @@ const deserializeAws_json1_1CreateStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1581,8 +1587,7 @@ const deserializeAws_json1_1DeleteCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1604,10 +1609,12 @@ const deserializeAws_json1_1DeleteCollectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1639,8 +1646,7 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1668,10 +1674,12 @@ const deserializeAws_json1_1DeleteDatasetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1703,8 +1711,7 @@ const deserializeAws_json1_1DeleteFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1726,10 +1733,12 @@ const deserializeAws_json1_1DeleteFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1761,8 +1770,7 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1787,10 +1795,12 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1822,8 +1832,7 @@ const deserializeAws_json1_1DeleteProjectVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1848,10 +1857,12 @@ const deserializeAws_json1_1DeleteProjectVersionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1883,8 +1894,7 @@ const deserializeAws_json1_1DeleteStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1909,10 +1919,12 @@ const deserializeAws_json1_1DeleteStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1944,8 +1956,7 @@ const deserializeAws_json1_1DescribeCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -1967,10 +1978,12 @@ const deserializeAws_json1_1DescribeCollectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2002,8 +2015,7 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2025,10 +2037,12 @@ const deserializeAws_json1_1DescribeDatasetCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2060,8 +2074,7 @@ const deserializeAws_json1_1DescribeProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2083,10 +2096,12 @@ const deserializeAws_json1_1DescribeProjectsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2118,8 +2133,7 @@ const deserializeAws_json1_1DescribeProjectVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2144,10 +2158,12 @@ const deserializeAws_json1_1DescribeProjectVersionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2179,8 +2195,7 @@ const deserializeAws_json1_1DescribeStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2202,10 +2217,12 @@ const deserializeAws_json1_1DescribeStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2237,8 +2254,7 @@ const deserializeAws_json1_1DetectCustomLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2275,10 +2291,12 @@ const deserializeAws_json1_1DetectCustomLabelsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2310,8 +2328,7 @@ const deserializeAws_json1_1DetectFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2339,10 +2356,12 @@ const deserializeAws_json1_1DetectFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2374,8 +2393,7 @@ const deserializeAws_json1_1DetectLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2403,10 +2421,12 @@ const deserializeAws_json1_1DetectLabelsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2438,8 +2458,7 @@ const deserializeAws_json1_1DetectModerationLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2470,10 +2489,12 @@ const deserializeAws_json1_1DetectModerationLabelsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2505,8 +2526,7 @@ const deserializeAws_json1_1DetectProtectiveEquipmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2534,10 +2554,12 @@ const deserializeAws_json1_1DetectProtectiveEquipmentCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2569,8 +2591,7 @@ const deserializeAws_json1_1DetectTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2598,10 +2619,12 @@ const deserializeAws_json1_1DetectTextCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2633,8 +2656,7 @@ const deserializeAws_json1_1DistributeDatasetEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2659,10 +2681,12 @@ const deserializeAws_json1_1DistributeDatasetEntriesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2694,8 +2718,7 @@ const deserializeAws_json1_1GetCelebrityInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2717,10 +2740,12 @@ const deserializeAws_json1_1GetCelebrityInfoCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2752,8 +2777,7 @@ const deserializeAws_json1_1GetCelebrityRecognitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2778,10 +2802,12 @@ const deserializeAws_json1_1GetCelebrityRecognitionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2813,8 +2839,7 @@ const deserializeAws_json1_1GetContentModerationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2839,10 +2864,12 @@ const deserializeAws_json1_1GetContentModerationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2874,8 +2901,7 @@ const deserializeAws_json1_1GetFaceDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2900,10 +2926,12 @@ const deserializeAws_json1_1GetFaceDetectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2935,8 +2963,7 @@ const deserializeAws_json1_1GetFaceSearchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -2961,10 +2988,12 @@ const deserializeAws_json1_1GetFaceSearchCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2996,8 +3025,7 @@ const deserializeAws_json1_1GetLabelDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3022,10 +3050,12 @@ const deserializeAws_json1_1GetLabelDetectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3057,8 +3087,7 @@ const deserializeAws_json1_1GetPersonTrackingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3083,10 +3112,12 @@ const deserializeAws_json1_1GetPersonTrackingCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3118,8 +3149,7 @@ const deserializeAws_json1_1GetSegmentDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3144,10 +3174,12 @@ const deserializeAws_json1_1GetSegmentDetectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3179,8 +3211,7 @@ const deserializeAws_json1_1GetTextDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3205,10 +3236,12 @@ const deserializeAws_json1_1GetTextDetectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3240,8 +3273,7 @@ const deserializeAws_json1_1IndexFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3275,10 +3307,12 @@ const deserializeAws_json1_1IndexFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3310,8 +3344,7 @@ const deserializeAws_json1_1ListCollectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3336,10 +3369,12 @@ const deserializeAws_json1_1ListCollectionsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3371,8 +3406,7 @@ const deserializeAws_json1_1ListDatasetEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3403,10 +3437,12 @@ const deserializeAws_json1_1ListDatasetEntriesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3438,8 +3474,7 @@ const deserializeAws_json1_1ListDatasetLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3470,10 +3505,12 @@ const deserializeAws_json1_1ListDatasetLabelsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3505,8 +3542,7 @@ const deserializeAws_json1_1ListFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3531,10 +3567,12 @@ const deserializeAws_json1_1ListFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3566,8 +3604,7 @@ const deserializeAws_json1_1ListStreamProcessorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3589,10 +3626,12 @@ const deserializeAws_json1_1ListStreamProcessorsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3624,8 +3663,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3647,10 +3685,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3682,8 +3722,7 @@ const deserializeAws_json1_1RecognizeCelebritiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3711,10 +3750,12 @@ const deserializeAws_json1_1RecognizeCelebritiesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3746,8 +3787,7 @@ const deserializeAws_json1_1SearchFacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3769,10 +3809,12 @@ const deserializeAws_json1_1SearchFacesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3804,8 +3846,7 @@ const deserializeAws_json1_1SearchFacesByImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3836,10 +3877,12 @@ const deserializeAws_json1_1SearchFacesByImageCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3871,8 +3914,7 @@ const deserializeAws_json1_1StartCelebrityRecognitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3903,10 +3945,12 @@ const deserializeAws_json1_1StartCelebrityRecognitionCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3938,8 +3982,7 @@ const deserializeAws_json1_1StartContentModerationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -3970,10 +4013,12 @@ const deserializeAws_json1_1StartContentModerationCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4005,8 +4050,7 @@ const deserializeAws_json1_1StartFaceDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4037,10 +4081,12 @@ const deserializeAws_json1_1StartFaceDetectionCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4072,8 +4118,7 @@ const deserializeAws_json1_1StartFaceSearchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4107,10 +4152,12 @@ const deserializeAws_json1_1StartFaceSearchCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4142,8 +4189,7 @@ const deserializeAws_json1_1StartLabelDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4174,10 +4220,12 @@ const deserializeAws_json1_1StartLabelDetectionCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4209,8 +4257,7 @@ const deserializeAws_json1_1StartPersonTrackingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4241,10 +4288,12 @@ const deserializeAws_json1_1StartPersonTrackingCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4276,8 +4325,7 @@ const deserializeAws_json1_1StartProjectVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4305,10 +4353,12 @@ const deserializeAws_json1_1StartProjectVersionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4340,8 +4390,7 @@ const deserializeAws_json1_1StartSegmentDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4372,10 +4421,12 @@ const deserializeAws_json1_1StartSegmentDetectionCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4407,8 +4458,7 @@ const deserializeAws_json1_1StartStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4433,10 +4483,12 @@ const deserializeAws_json1_1StartStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4468,8 +4520,7 @@ const deserializeAws_json1_1StartTextDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4500,10 +4551,12 @@ const deserializeAws_json1_1StartTextDetectionCommandError = async ( throw await deserializeAws_json1_1VideoTooLargeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4535,8 +4588,7 @@ const deserializeAws_json1_1StopProjectVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4561,10 +4613,12 @@ const deserializeAws_json1_1StopProjectVersionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4596,8 +4650,7 @@ const deserializeAws_json1_1StopStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4622,10 +4675,12 @@ const deserializeAws_json1_1StopStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4657,8 +4712,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4683,10 +4737,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4718,8 +4774,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4741,10 +4796,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4776,8 +4833,7 @@ const deserializeAws_json1_1UpdateDatasetEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4805,10 +4861,12 @@ const deserializeAws_json1_1UpdateDatasetEntriesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4840,8 +4898,7 @@ const deserializeAws_json1_1UpdateStreamProcessorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rekognition#AccessDeniedException": @@ -4863,10 +4920,12 @@ const deserializeAws_json1_1UpdateStreamProcessorCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8949,7 +9008,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8975,6 +9034,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-resiliencehub/src/protocols/Aws_restJson1.ts b/clients/client-resiliencehub/src/protocols/Aws_restJson1.ts index 4a836406f599e..9d877de481599 100644 --- a/clients/client-resiliencehub/src/protocols/Aws_restJson1.ts +++ b/clients/client-resiliencehub/src/protocols/Aws_restJson1.ts @@ -1335,8 +1335,7 @@ const deserializeAws_restJson1AddDraftAppVersionResourceMappingsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1358,10 +1357,12 @@ const deserializeAws_restJson1AddDraftAppVersionResourceMappingsCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1394,8 +1395,7 @@ const deserializeAws_restJson1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1420,10 +1420,12 @@ const deserializeAws_restJson1CreateAppCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1459,8 +1461,7 @@ const deserializeAws_restJson1CreateRecommendationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1482,10 +1483,12 @@ const deserializeAws_restJson1CreateRecommendationTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1518,8 +1521,7 @@ const deserializeAws_restJson1CreateResiliencyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1541,10 +1543,12 @@ const deserializeAws_restJson1CreateResiliencyPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1577,8 +1581,7 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.resiliencehub#ConflictException": @@ -1597,10 +1600,12 @@ const deserializeAws_restJson1DeleteAppCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1637,8 +1642,7 @@ const deserializeAws_restJson1DeleteAppAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1660,10 +1664,12 @@ const deserializeAws_restJson1DeleteAppAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1700,8 +1706,7 @@ const deserializeAws_restJson1DeleteRecommendationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1720,10 +1725,12 @@ const deserializeAws_restJson1DeleteRecommendationTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1756,8 +1763,7 @@ const deserializeAws_restJson1DeleteResiliencyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1779,10 +1785,12 @@ const deserializeAws_restJson1DeleteResiliencyPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1815,8 +1823,7 @@ const deserializeAws_restJson1DescribeAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1835,10 +1842,12 @@ const deserializeAws_restJson1DescribeAppCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1871,8 +1880,7 @@ const deserializeAws_restJson1DescribeAppAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1891,10 +1899,12 @@ const deserializeAws_restJson1DescribeAppAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1953,7 @@ const deserializeAws_restJson1DescribeAppVersionResourcesResolutionStatusCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -1963,10 +1972,12 @@ const deserializeAws_restJson1DescribeAppVersionResourcesResolutionStatusCommand throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2007,8 +2018,7 @@ const deserializeAws_restJson1DescribeAppVersionTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2027,10 +2037,12 @@ const deserializeAws_restJson1DescribeAppVersionTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2079,8 +2091,7 @@ const deserializeAws_restJson1DescribeDraftAppVersionResourcesImportStatusComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2099,10 +2110,12 @@ const deserializeAws_restJson1DescribeDraftAppVersionResourcesImportStatusComman throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2135,8 +2148,7 @@ const deserializeAws_restJson1DescribeResiliencyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2155,10 +2167,12 @@ const deserializeAws_restJson1DescribeResiliencyPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2207,8 +2221,7 @@ const deserializeAws_restJson1ImportResourcesToDraftAppVersionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2230,10 +2243,12 @@ const deserializeAws_restJson1ImportResourcesToDraftAppVersionCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2270,8 +2285,7 @@ const deserializeAws_restJson1ListAlarmRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2290,10 +2304,12 @@ const deserializeAws_restJson1ListAlarmRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2330,8 +2346,7 @@ const deserializeAws_restJson1ListAppAssessmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2350,10 +2365,12 @@ const deserializeAws_restJson1ListAppAssessmentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2393,8 +2410,7 @@ const deserializeAws_restJson1ListAppComponentCompliancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2413,10 +2429,12 @@ const deserializeAws_restJson1ListAppComponentCompliancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2456,8 +2474,7 @@ const deserializeAws_restJson1ListAppComponentRecommendationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2476,10 +2493,12 @@ const deserializeAws_restJson1ListAppComponentRecommendationsCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2516,8 +2535,7 @@ const deserializeAws_restJson1ListAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2533,10 +2551,12 @@ const deserializeAws_restJson1ListAppsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2573,8 +2593,7 @@ const deserializeAws_restJson1ListAppVersionResourceMappingsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2593,10 +2612,12 @@ const deserializeAws_restJson1ListAppVersionResourceMappingsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2637,8 +2658,7 @@ const deserializeAws_restJson1ListAppVersionResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2660,10 +2680,12 @@ const deserializeAws_restJson1ListAppVersionResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2700,8 +2722,7 @@ const deserializeAws_restJson1ListAppVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2717,10 +2738,12 @@ const deserializeAws_restJson1ListAppVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2760,8 +2783,7 @@ const deserializeAws_restJson1ListRecommendationTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2777,10 +2799,12 @@ const deserializeAws_restJson1ListRecommendationTemplatesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2817,8 +2841,7 @@ const deserializeAws_restJson1ListResiliencyPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2837,10 +2860,12 @@ const deserializeAws_restJson1ListResiliencyPoliciesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2877,8 +2902,7 @@ const deserializeAws_restJson1ListSopRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2900,10 +2924,12 @@ const deserializeAws_restJson1ListSopRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2940,8 +2966,7 @@ const deserializeAws_restJson1ListSuggestedResiliencyPoliciesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -2960,10 +2985,12 @@ const deserializeAws_restJson1ListSuggestedResiliencyPoliciesCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2996,8 +3023,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3016,10 +3042,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3056,8 +3084,7 @@ const deserializeAws_restJson1ListTestRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3079,10 +3106,12 @@ const deserializeAws_restJson1ListTestRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3123,8 +3152,7 @@ const deserializeAws_restJson1ListUnsupportedAppVersionResourcesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3146,10 +3174,12 @@ const deserializeAws_restJson1ListUnsupportedAppVersionResourcesCommandError = a throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3186,8 +3216,7 @@ const deserializeAws_restJson1PublishAppVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3209,10 +3238,12 @@ const deserializeAws_restJson1PublishAppVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3249,8 +3280,7 @@ const deserializeAws_restJson1PutDraftAppVersionTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3272,10 +3302,12 @@ const deserializeAws_restJson1PutDraftAppVersionTemplateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3312,8 +3344,7 @@ const deserializeAws_restJson1RemoveDraftAppVersionResourceMappingsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3335,10 +3366,12 @@ const deserializeAws_restJson1RemoveDraftAppVersionResourceMappingsCommandError throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3383,8 +3416,7 @@ const deserializeAws_restJson1ResolveAppVersionResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3406,10 +3438,12 @@ const deserializeAws_restJson1ResolveAppVersionResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3442,8 +3476,7 @@ const deserializeAws_restJson1StartAppAssessmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3468,10 +3501,12 @@ const deserializeAws_restJson1StartAppAssessmentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3500,8 +3535,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3520,10 +3554,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3552,8 +3588,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3572,10 +3607,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3608,8 +3645,7 @@ const deserializeAws_restJson1UpdateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3631,10 +3667,12 @@ const deserializeAws_restJson1UpdateAppCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3667,8 +3705,7 @@ const deserializeAws_restJson1UpdateResiliencyPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.resiliencehub#AccessDeniedException": @@ -3690,10 +3727,12 @@ const deserializeAws_restJson1UpdateResiliencyPolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4858,7 +4897,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4884,6 +4923,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-resource-groups-tagging-api/src/protocols/Aws_json1_1.ts b/clients/client-resource-groups-tagging-api/src/protocols/Aws_json1_1.ts index 671aa7ed9e8f1..b453b531c6e0d 100644 --- a/clients/client-resource-groups-tagging-api/src/protocols/Aws_json1_1.ts +++ b/clients/client-resource-groups-tagging-api/src/protocols/Aws_json1_1.ts @@ -194,8 +194,7 @@ const deserializeAws_json1_1DescribeReportCreationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConstraintViolationException": case "com.amazonaws.resourcegroupstaggingapi#ConstraintViolationException": @@ -211,10 +210,12 @@ const deserializeAws_json1_1DescribeReportCreationCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -246,8 +247,7 @@ const deserializeAws_json1_1GetComplianceSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConstraintViolationException": case "com.amazonaws.resourcegroupstaggingapi#ConstraintViolationException": @@ -263,10 +263,12 @@ const deserializeAws_json1_1GetComplianceSummaryCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -298,8 +300,7 @@ const deserializeAws_json1_1GetResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.resourcegroupstaggingapi#InternalServiceException": @@ -315,10 +316,12 @@ const deserializeAws_json1_1GetResourcesCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -350,8 +353,7 @@ const deserializeAws_json1_1GetTagKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.resourcegroupstaggingapi#InternalServiceException": @@ -367,10 +369,12 @@ const deserializeAws_json1_1GetTagKeysCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -402,8 +406,7 @@ const deserializeAws_json1_1GetTagValuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.resourcegroupstaggingapi#InternalServiceException": @@ -419,10 +422,12 @@ const deserializeAws_json1_1GetTagValuesCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -454,8 +459,7 @@ const deserializeAws_json1_1StartReportCreationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.resourcegroupstaggingapi#ConcurrentModificationException": @@ -474,10 +478,12 @@ const deserializeAws_json1_1StartReportCreationCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -509,8 +515,7 @@ const deserializeAws_json1_1TagResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.resourcegroupstaggingapi#InternalServiceException": @@ -523,10 +528,12 @@ const deserializeAws_json1_1TagResourcesCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -558,8 +565,7 @@ const deserializeAws_json1_1UntagResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.resourcegroupstaggingapi#InternalServiceException": @@ -572,10 +578,12 @@ const deserializeAws_json1_1UntagResourcesCommandError = async ( throw await deserializeAws_json1_1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,7 +1217,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1235,6 +1243,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-resource-groups/src/protocols/Aws_restJson1.ts b/clients/client-resource-groups/src/protocols/Aws_restJson1.ts index 74ee541be5c52..92cdca6d4e452 100644 --- a/clients/client-resource-groups/src/protocols/Aws_restJson1.ts +++ b/clients/client-resource-groups/src/protocols/Aws_restJson1.ts @@ -557,8 +557,7 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -577,10 +576,12 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -613,8 +614,7 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -636,10 +636,12 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -672,8 +674,7 @@ const deserializeAws_restJson1GetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -695,10 +696,12 @@ const deserializeAws_restJson1GetGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -731,8 +734,7 @@ const deserializeAws_restJson1GetGroupConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -754,10 +756,12 @@ const deserializeAws_restJson1GetGroupConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -790,8 +794,7 @@ const deserializeAws_restJson1GetGroupQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -813,10 +816,12 @@ const deserializeAws_restJson1GetGroupQueryCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -853,8 +858,7 @@ const deserializeAws_restJson1GetTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -876,10 +880,12 @@ const deserializeAws_restJson1GetTagsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -920,8 +926,7 @@ const deserializeAws_restJson1GroupResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -943,10 +948,12 @@ const deserializeAws_restJson1GroupResourcesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -991,8 +998,7 @@ const deserializeAws_restJson1ListGroupResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1017,10 +1023,12 @@ const deserializeAws_restJson1ListGroupResourcesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1061,8 +1069,7 @@ const deserializeAws_restJson1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1081,10 +1088,12 @@ const deserializeAws_restJson1ListGroupsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1113,8 +1122,7 @@ const deserializeAws_restJson1PutGroupConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1136,10 +1144,12 @@ const deserializeAws_restJson1PutGroupConfigurationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1180,8 +1190,7 @@ const deserializeAws_restJson1SearchResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1203,10 +1212,12 @@ const deserializeAws_restJson1SearchResourcesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1243,8 +1254,7 @@ const deserializeAws_restJson1TagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1266,10 +1276,12 @@ const deserializeAws_restJson1TagCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1310,8 +1322,7 @@ const deserializeAws_restJson1UngroupResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1333,10 +1344,12 @@ const deserializeAws_restJson1UngroupResourcesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1373,8 +1386,7 @@ const deserializeAws_restJson1UntagCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1396,10 +1408,12 @@ const deserializeAws_restJson1UntagCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1432,8 +1446,7 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1455,10 +1468,12 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1491,8 +1506,7 @@ const deserializeAws_restJson1UpdateGroupQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.resourcegroups#BadRequestException": @@ -1514,10 +1528,12 @@ const deserializeAws_restJson1UpdateGroupQueryCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2124,7 +2140,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2150,6 +2166,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-robomaker/src/protocols/Aws_restJson1.ts b/clients/client-robomaker/src/protocols/Aws_restJson1.ts index 956d9c1bbbabd..135f3da369377 100644 --- a/clients/client-robomaker/src/protocols/Aws_restJson1.ts +++ b/clients/client-robomaker/src/protocols/Aws_restJson1.ts @@ -1893,8 +1893,7 @@ const deserializeAws_restJson1BatchDeleteWorldsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -1907,10 +1906,12 @@ const deserializeAws_restJson1BatchDeleteWorldsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1947,8 +1948,7 @@ const deserializeAws_restJson1BatchDescribeSimulationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -1964,10 +1964,12 @@ const deserializeAws_restJson1BatchDescribeSimulationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1996,8 +1998,7 @@ const deserializeAws_restJson1CancelDeploymentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2013,10 +2014,12 @@ const deserializeAws_restJson1CancelDeploymentJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2048,7 @@ const deserializeAws_restJson1CancelSimulationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2062,10 +2064,12 @@ const deserializeAws_restJson1CancelSimulationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2094,8 +2098,7 @@ const deserializeAws_restJson1CancelSimulationJobBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2111,10 +2114,12 @@ const deserializeAws_restJson1CancelSimulationJobBatchCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2143,8 +2148,7 @@ const deserializeAws_restJson1CancelWorldExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2160,10 +2164,12 @@ const deserializeAws_restJson1CancelWorldExportJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2192,8 +2198,7 @@ const deserializeAws_restJson1CancelWorldGenerationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2209,10 +2214,12 @@ const deserializeAws_restJson1CancelWorldGenerationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2280,8 +2287,7 @@ const deserializeAws_restJson1CreateDeploymentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentDeploymentException": case "com.amazonaws.robomaker#ConcurrentDeploymentException": @@ -2306,10 +2312,12 @@ const deserializeAws_restJson1CreateDeploymentJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2354,8 +2362,7 @@ const deserializeAws_restJson1CreateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2371,10 +2378,12 @@ const deserializeAws_restJson1CreateFleetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2427,8 +2436,7 @@ const deserializeAws_restJson1CreateRobotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -2447,10 +2455,12 @@ const deserializeAws_restJson1CreateRobotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2515,8 +2525,7 @@ const deserializeAws_restJson1CreateRobotApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -2538,10 +2547,12 @@ const deserializeAws_restJson1CreateRobotApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2602,8 +2613,7 @@ const deserializeAws_restJson1CreateRobotApplicationVersionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -2622,10 +2632,12 @@ const deserializeAws_restJson1CreateRobotApplicationVersionCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2701,8 +2713,7 @@ const deserializeAws_restJson1CreateSimulationApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -2724,10 +2735,12 @@ const deserializeAws_restJson1CreateSimulationApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2799,8 +2812,7 @@ const deserializeAws_restJson1CreateSimulationApplicationVersionCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -2819,10 +2831,12 @@ const deserializeAws_restJson1CreateSimulationApplicationVersionCommandError = a throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2926,8 +2940,7 @@ const deserializeAws_restJson1CreateSimulationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -2952,10 +2965,12 @@ const deserializeAws_restJson1CreateSimulationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3016,8 +3031,7 @@ const deserializeAws_restJson1CreateWorldExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -3039,10 +3053,12 @@ const deserializeAws_restJson1CreateWorldExportJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3107,8 +3123,7 @@ const deserializeAws_restJson1CreateWorldGenerationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -3133,10 +3148,12 @@ const deserializeAws_restJson1CreateWorldGenerationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3185,8 +3202,7 @@ const deserializeAws_restJson1CreateWorldTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3208,10 +3224,12 @@ const deserializeAws_restJson1CreateWorldTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3240,8 +3258,7 @@ const deserializeAws_restJson1DeleteFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3254,10 +3271,12 @@ const deserializeAws_restJson1DeleteFleetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3286,8 +3305,7 @@ const deserializeAws_restJson1DeleteRobotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3300,10 +3318,12 @@ const deserializeAws_restJson1DeleteRobotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3332,8 +3352,7 @@ const deserializeAws_restJson1DeleteRobotApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3346,10 +3365,12 @@ const deserializeAws_restJson1DeleteRobotApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3378,8 +3399,7 @@ const deserializeAws_restJson1DeleteSimulationApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3392,10 +3412,12 @@ const deserializeAws_restJson1DeleteSimulationApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3424,8 +3446,7 @@ const deserializeAws_restJson1DeleteWorldTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3441,10 +3462,12 @@ const deserializeAws_restJson1DeleteWorldTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3481,8 +3504,7 @@ const deserializeAws_restJson1DeregisterRobotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3498,10 +3520,12 @@ const deserializeAws_restJson1DeregisterRobotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3576,8 +3600,7 @@ const deserializeAws_restJson1DescribeDeploymentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3593,10 +3616,12 @@ const deserializeAws_restJson1DescribeDeploymentJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3657,8 +3682,7 @@ const deserializeAws_restJson1DescribeFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3674,10 +3698,12 @@ const deserializeAws_restJson1DescribeFleetCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3746,8 +3772,7 @@ const deserializeAws_restJson1DescribeRobotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3763,10 +3788,12 @@ const deserializeAws_restJson1DescribeRobotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3835,8 +3862,7 @@ const deserializeAws_restJson1DescribeRobotApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3852,10 +3878,12 @@ const deserializeAws_restJson1DescribeRobotApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3935,8 +3963,7 @@ const deserializeAws_restJson1DescribeSimulationApplicationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -3952,10 +3979,12 @@ const deserializeAws_restJson1DescribeSimulationApplicationCommandError = async throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4071,8 +4100,7 @@ const deserializeAws_restJson1DescribeSimulationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4088,10 +4116,12 @@ const deserializeAws_restJson1DescribeSimulationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4168,8 +4198,7 @@ const deserializeAws_restJson1DescribeSimulationJobBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4182,10 +4211,12 @@ const deserializeAws_restJson1DescribeSimulationJobBatchCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4238,8 +4269,7 @@ const deserializeAws_restJson1DescribeWorldCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4255,10 +4285,12 @@ const deserializeAws_restJson1DescribeWorldCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4327,8 +4359,7 @@ const deserializeAws_restJson1DescribeWorldExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4344,10 +4375,12 @@ const deserializeAws_restJson1DescribeWorldExportJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4420,8 +4453,7 @@ const deserializeAws_restJson1DescribeWorldGenerationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4437,10 +4469,12 @@ const deserializeAws_restJson1DescribeWorldGenerationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4497,8 +4531,7 @@ const deserializeAws_restJson1DescribeWorldTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4514,10 +4547,12 @@ const deserializeAws_restJson1DescribeWorldTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4550,8 +4585,7 @@ const deserializeAws_restJson1GetWorldTemplateBodyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4567,10 +4601,12 @@ const deserializeAws_restJson1GetWorldTemplateBodyCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4607,8 +4643,7 @@ const deserializeAws_restJson1ListDeploymentJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4624,10 +4659,12 @@ const deserializeAws_restJson1ListDeploymentJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4664,8 +4701,7 @@ const deserializeAws_restJson1ListFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4681,10 +4717,12 @@ const deserializeAws_restJson1ListFleetsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4724,8 +4762,7 @@ const deserializeAws_restJson1ListRobotApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4738,10 +4775,12 @@ const deserializeAws_restJson1ListRobotApplicationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4778,8 +4817,7 @@ const deserializeAws_restJson1ListRobotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4795,10 +4833,12 @@ const deserializeAws_restJson1ListRobotsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4838,8 +4878,7 @@ const deserializeAws_restJson1ListSimulationApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4852,10 +4891,12 @@ const deserializeAws_restJson1ListSimulationApplicationsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4895,8 +4936,7 @@ const deserializeAws_restJson1ListSimulationJobBatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4906,10 +4946,12 @@ const deserializeAws_restJson1ListSimulationJobBatchesCommandError = async ( throw await deserializeAws_restJson1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4949,8 +4991,7 @@ const deserializeAws_restJson1ListSimulationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -4963,10 +5004,12 @@ const deserializeAws_restJson1ListSimulationJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4999,8 +5042,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5016,10 +5058,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5059,8 +5103,7 @@ const deserializeAws_restJson1ListWorldExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5073,10 +5116,12 @@ const deserializeAws_restJson1ListWorldExportJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5116,8 +5161,7 @@ const deserializeAws_restJson1ListWorldGenerationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5130,10 +5174,12 @@ const deserializeAws_restJson1ListWorldGenerationJobsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5170,8 +5216,7 @@ const deserializeAws_restJson1ListWorldsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5184,10 +5229,12 @@ const deserializeAws_restJson1ListWorldsCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5224,8 +5271,7 @@ const deserializeAws_restJson1ListWorldTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5238,10 +5284,12 @@ const deserializeAws_restJson1ListWorldTemplatesCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5278,8 +5326,7 @@ const deserializeAws_restJson1RegisterRobotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5298,10 +5345,12 @@ const deserializeAws_restJson1RegisterRobotCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5330,8 +5379,7 @@ const deserializeAws_restJson1RestartSimulationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5350,10 +5398,12 @@ const deserializeAws_restJson1RestartSimulationJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5426,8 +5476,7 @@ const deserializeAws_restJson1StartSimulationJobBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatchException": case "com.amazonaws.robomaker#IdempotentParameterMismatchException": @@ -5446,10 +5495,12 @@ const deserializeAws_restJson1StartSimulationJobBatchCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5513,8 +5564,7 @@ const deserializeAws_restJson1SyncDeploymentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentDeploymentException": case "com.amazonaws.robomaker#ConcurrentDeploymentException": @@ -5539,10 +5589,12 @@ const deserializeAws_restJson1SyncDeploymentJobCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5571,8 +5623,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5588,10 +5639,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5620,8 +5673,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5637,10 +5689,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5701,8 +5755,7 @@ const deserializeAws_restJson1UpdateRobotApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5721,10 +5774,12 @@ const deserializeAws_restJson1UpdateRobotApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5796,8 +5851,7 @@ const deserializeAws_restJson1UpdateSimulationApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5816,10 +5870,12 @@ const deserializeAws_restJson1UpdateSimulationApplicationCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5864,8 +5920,7 @@ const deserializeAws_restJson1UpdateWorldTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.robomaker#InternalServerException": @@ -5881,10 +5936,12 @@ const deserializeAws_restJson1UpdateWorldTemplateCommandError = async ( throw await deserializeAws_restJson1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7821,7 +7878,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7847,6 +7904,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-route-53-domains/src/protocols/Aws_json1_1.ts b/clients/client-route-53-domains/src/protocols/Aws_json1_1.ts index 0410a8deac6e4..2e80c242b934f 100644 --- a/clients/client-route-53-domains/src/protocols/Aws_json1_1.ts +++ b/clients/client-route-53-domains/src/protocols/Aws_json1_1.ts @@ -602,8 +602,7 @@ const deserializeAws_json1_1AcceptDomainTransferFromAnotherAwsAccountCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainLimitExceeded": case "com.amazonaws.route53domains#DomainLimitExceeded": @@ -619,10 +618,12 @@ const deserializeAws_json1_1AcceptDomainTransferFromAnotherAwsAccountCommandErro throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -654,8 +655,7 @@ const deserializeAws_json1_1CancelDomainTransferToAnotherAwsAccountCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -668,10 +668,12 @@ const deserializeAws_json1_1CancelDomainTransferToAnotherAwsAccountCommandError throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -703,8 +705,7 @@ const deserializeAws_json1_1CheckDomainAvailabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -714,10 +715,12 @@ const deserializeAws_json1_1CheckDomainAvailabilityCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -749,8 +752,7 @@ const deserializeAws_json1_1CheckDomainTransferabilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -760,10 +762,12 @@ const deserializeAws_json1_1CheckDomainTransferabilityCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -795,8 +799,7 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -812,10 +815,12 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -847,8 +852,7 @@ const deserializeAws_json1_1DeleteTagsForDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -861,10 +865,12 @@ const deserializeAws_json1_1DeleteTagsForDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -896,8 +902,7 @@ const deserializeAws_json1_1DisableDomainAutoRenewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -907,10 +912,12 @@ const deserializeAws_json1_1DisableDomainAutoRenewCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -942,8 +949,7 @@ const deserializeAws_json1_1DisableDomainTransferLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -962,10 +968,12 @@ const deserializeAws_json1_1DisableDomainTransferLockCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -997,8 +1005,7 @@ const deserializeAws_json1_1EnableDomainAutoRenewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1011,10 +1018,12 @@ const deserializeAws_json1_1EnableDomainAutoRenewCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1046,8 +1055,7 @@ const deserializeAws_json1_1EnableDomainTransferLockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1066,10 +1074,12 @@ const deserializeAws_json1_1EnableDomainTransferLockCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1101,8 +1111,7 @@ const deserializeAws_json1_1GetContactReachabilityStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1115,10 +1124,12 @@ const deserializeAws_json1_1GetContactReachabilityStatusCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1150,8 +1161,7 @@ const deserializeAws_json1_1GetDomainDetailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1161,10 +1171,12 @@ const deserializeAws_json1_1GetDomainDetailCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1196,8 +1208,7 @@ const deserializeAws_json1_1GetDomainSuggestionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1207,10 +1218,12 @@ const deserializeAws_json1_1GetDomainSuggestionsCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1242,18 +1255,19 @@ const deserializeAws_json1_1GetOperationDetailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1285,18 +1299,19 @@ const deserializeAws_json1_1ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1328,18 +1343,19 @@ const deserializeAws_json1_1ListOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1371,8 +1387,7 @@ const deserializeAws_json1_1ListPricesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1382,10 +1397,12 @@ const deserializeAws_json1_1ListPricesCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1417,8 +1434,7 @@ const deserializeAws_json1_1ListTagsForDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1431,10 +1447,12 @@ const deserializeAws_json1_1ListTagsForDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1466,8 +1484,7 @@ const deserializeAws_json1_1RegisterDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainLimitExceeded": case "com.amazonaws.route53domains#DomainLimitExceeded": @@ -1489,10 +1506,12 @@ const deserializeAws_json1_1RegisterDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1524,8 +1543,7 @@ const deserializeAws_json1_1RejectDomainTransferFromAnotherAwsAccountCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1538,10 +1556,12 @@ const deserializeAws_json1_1RejectDomainTransferFromAnotherAwsAccountCommandErro throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1573,8 +1593,7 @@ const deserializeAws_json1_1RenewDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1593,10 +1612,12 @@ const deserializeAws_json1_1RenewDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1628,8 +1649,7 @@ const deserializeAws_json1_1ResendContactReachabilityEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1642,10 +1662,12 @@ const deserializeAws_json1_1ResendContactReachabilityEmailCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,8 +1699,7 @@ const deserializeAws_json1_1RetrieveDomainAuthCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -1688,10 +1709,12 @@ const deserializeAws_json1_1RetrieveDomainAuthCodeCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1723,8 +1746,7 @@ const deserializeAws_json1_1TransferDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainLimitExceeded": case "com.amazonaws.route53domains#DomainLimitExceeded": @@ -1746,10 +1768,12 @@ const deserializeAws_json1_1TransferDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1781,8 +1805,7 @@ const deserializeAws_json1_1TransferDomainToAnotherAwsAccountCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1798,10 +1821,12 @@ const deserializeAws_json1_1TransferDomainToAnotherAwsAccountCommandError = asyn throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1833,8 +1858,7 @@ const deserializeAws_json1_1UpdateDomainContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1853,10 +1877,12 @@ const deserializeAws_json1_1UpdateDomainContactCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1888,8 +1914,7 @@ const deserializeAws_json1_1UpdateDomainContactPrivacyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1908,10 +1933,12 @@ const deserializeAws_json1_1UpdateDomainContactPrivacyCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1970,7 @@ const deserializeAws_json1_1UpdateDomainNameserversCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.route53domains#DuplicateRequest": @@ -1963,10 +1989,12 @@ const deserializeAws_json1_1UpdateDomainNameserversCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1998,8 +2026,7 @@ const deserializeAws_json1_1UpdateTagsForDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": @@ -2012,10 +2039,12 @@ const deserializeAws_json1_1UpdateTagsForDomainCommandError = async ( throw await deserializeAws_json1_1UnsupportedTLDResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2047,18 +2076,19 @@ const deserializeAws_json1_1ViewBillingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53domains#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3270,7 +3300,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3296,6 +3326,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-route-53/src/protocols/Aws_restXml.ts b/clients/client-route-53/src/protocols/Aws_restXml.ts index fb08b6c915b84..3fc24bc052654 100644 --- a/clients/client-route-53/src/protocols/Aws_restXml.ts +++ b/clients/client-route-53/src/protocols/Aws_restXml.ts @@ -2860,8 +2860,7 @@ const deserializeAws_restXmlActivateKeySigningKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -2883,10 +2882,12 @@ const deserializeAws_restXmlActivateKeySigningKeyCommandError = async ( throw await deserializeAws_restXmlNoSuchKeySigningKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2919,8 +2920,7 @@ const deserializeAws_restXmlAssociateVPCWithHostedZoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingDomainExists": case "com.amazonaws.route53#ConflictingDomainExists": @@ -2948,10 +2948,12 @@ const deserializeAws_restXmlAssociateVPCWithHostedZoneCommandError = async ( throw await deserializeAws_restXmlPublicZoneVPCAssociationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2984,8 +2986,7 @@ const deserializeAws_restXmlChangeCidrCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "CidrBlockInUseException": case "com.amazonaws.route53#CidrBlockInUseException": @@ -3007,10 +3008,12 @@ const deserializeAws_restXmlChangeCidrCollectionCommandError = async ( throw await deserializeAws_restXmlNoSuchCidrCollectionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3043,8 +3046,7 @@ const deserializeAws_restXmlChangeResourceRecordSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidChangeBatch": case "com.amazonaws.route53#InvalidChangeBatch": @@ -3063,10 +3065,12 @@ const deserializeAws_restXmlChangeResourceRecordSetsCommandError = async ( throw await deserializeAws_restXmlPriorRequestNotCompleteResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3095,8 +3099,7 @@ const deserializeAws_restXmlChangeTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -3115,10 +3118,12 @@ const deserializeAws_restXmlChangeTagsForResourceCommandError = async ( throw await deserializeAws_restXmlThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3155,8 +3160,7 @@ const deserializeAws_restXmlCreateCidrCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "CidrCollectionAlreadyExistsException": case "com.amazonaws.route53#CidrCollectionAlreadyExistsException": @@ -3172,10 +3176,12 @@ const deserializeAws_restXmlCreateCidrCollectionCommandError = async ( throw await deserializeAws_restXmlLimitsExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3212,8 +3218,7 @@ const deserializeAws_restXmlCreateHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "HealthCheckAlreadyExists": case "com.amazonaws.route53#HealthCheckAlreadyExists": @@ -3226,10 +3231,12 @@ const deserializeAws_restXmlCreateHealthCheckCommandError = async ( throw await deserializeAws_restXmlTooManyHealthChecksResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3278,8 +3285,7 @@ const deserializeAws_restXmlCreateHostedZoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingDomainExists": case "com.amazonaws.route53#ConflictingDomainExists": @@ -3310,10 +3316,12 @@ const deserializeAws_restXmlCreateHostedZoneCommandError = async ( throw await deserializeAws_restXmlTooManyHostedZonesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3354,8 +3362,7 @@ const deserializeAws_restXmlCreateKeySigningKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -3389,10 +3396,12 @@ const deserializeAws_restXmlCreateKeySigningKeyCommandError = async ( throw await deserializeAws_restXmlTooManyKeySigningKeysResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3429,8 +3438,7 @@ const deserializeAws_restXmlCreateQueryLoggingConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -3452,10 +3460,12 @@ const deserializeAws_restXmlCreateQueryLoggingConfigCommandError = async ( throw await deserializeAws_restXmlQueryLoggingConfigAlreadyExistsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3492,8 +3502,7 @@ const deserializeAws_restXmlCreateReusableDelegationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "DelegationSetAlreadyCreated": case "com.amazonaws.route53#DelegationSetAlreadyCreated": @@ -3518,10 +3527,12 @@ const deserializeAws_restXmlCreateReusableDelegationSetCommandError = async ( throw await deserializeAws_restXmlLimitsExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3558,8 +3569,7 @@ const deserializeAws_restXmlCreateTrafficPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -3575,10 +3585,12 @@ const deserializeAws_restXmlCreateTrafficPolicyCommandError = async ( throw await deserializeAws_restXmlTrafficPolicyAlreadyExistsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3618,8 +3630,7 @@ const deserializeAws_restXmlCreateTrafficPolicyInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -3638,10 +3649,12 @@ const deserializeAws_restXmlCreateTrafficPolicyInstanceCommandError = async ( throw await deserializeAws_restXmlTrafficPolicyInstanceAlreadyExistsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3678,8 +3691,7 @@ const deserializeAws_restXmlCreateTrafficPolicyVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -3698,10 +3710,12 @@ const deserializeAws_restXmlCreateTrafficPolicyVersionCommandError = async ( throw await deserializeAws_restXmlTooManyTrafficPolicyVersionsForCurrentPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3738,8 +3752,7 @@ const deserializeAws_restXmlCreateVPCAssociationAuthorizationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -3758,10 +3771,12 @@ const deserializeAws_restXmlCreateVPCAssociationAuthorizationCommandError = asyn throw await deserializeAws_restXmlTooManyVPCAssociationAuthorizationsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3794,8 +3809,7 @@ const deserializeAws_restXmlDeactivateKeySigningKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -3820,10 +3834,12 @@ const deserializeAws_restXmlDeactivateKeySigningKeyCommandError = async ( throw await deserializeAws_restXmlNoSuchKeySigningKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3852,8 +3868,7 @@ const deserializeAws_restXmlDeleteCidrCollectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "CidrCollectionInUseException": case "com.amazonaws.route53#CidrCollectionInUseException": @@ -3869,10 +3884,12 @@ const deserializeAws_restXmlDeleteCidrCollectionCommandError = async ( throw await deserializeAws_restXmlNoSuchCidrCollectionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3901,8 +3918,7 @@ const deserializeAws_restXmlDeleteHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "HealthCheckInUse": case "com.amazonaws.route53#HealthCheckInUse": @@ -3915,10 +3931,12 @@ const deserializeAws_restXmlDeleteHealthCheckCommandError = async ( throw await deserializeAws_restXmlNoSuchHealthCheckResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3951,8 +3969,7 @@ const deserializeAws_restXmlDeleteHostedZoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "HostedZoneNotEmpty": case "com.amazonaws.route53#HostedZoneNotEmpty": @@ -3971,10 +3988,12 @@ const deserializeAws_restXmlDeleteHostedZoneCommandError = async ( throw await deserializeAws_restXmlPriorRequestNotCompleteResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4007,8 +4026,7 @@ const deserializeAws_restXmlDeleteKeySigningKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4030,10 +4048,12 @@ const deserializeAws_restXmlDeleteKeySigningKeyCommandError = async ( throw await deserializeAws_restXmlNoSuchKeySigningKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4062,8 +4082,7 @@ const deserializeAws_restXmlDeleteQueryLoggingConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4076,10 +4095,12 @@ const deserializeAws_restXmlDeleteQueryLoggingConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchQueryLoggingConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4108,8 +4129,7 @@ const deserializeAws_restXmlDeleteReusableDelegationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "DelegationSetInUse": case "com.amazonaws.route53#DelegationSetInUse": @@ -4125,10 +4145,12 @@ const deserializeAws_restXmlDeleteReusableDelegationSetCommandError = async ( throw await deserializeAws_restXmlNoSuchDelegationSetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4157,8 +4179,7 @@ const deserializeAws_restXmlDeleteTrafficPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4174,10 +4195,12 @@ const deserializeAws_restXmlDeleteTrafficPolicyCommandError = async ( throw await deserializeAws_restXmlTrafficPolicyInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4206,8 +4229,7 @@ const deserializeAws_restXmlDeleteTrafficPolicyInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4220,10 +4242,12 @@ const deserializeAws_restXmlDeleteTrafficPolicyInstanceCommandError = async ( throw await deserializeAws_restXmlPriorRequestNotCompleteResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4252,8 +4276,7 @@ const deserializeAws_restXmlDeleteVPCAssociationAuthorizationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4272,10 +4295,12 @@ const deserializeAws_restXmlDeleteVPCAssociationAuthorizationCommandError = asyn throw await deserializeAws_restXmlVPCAssociationAuthorizationNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4308,8 +4333,7 @@ const deserializeAws_restXmlDisableHostedZoneDNSSECCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4337,10 +4361,12 @@ const deserializeAws_restXmlDisableHostedZoneDNSSECCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4373,8 +4399,7 @@ const deserializeAws_restXmlDisassociateVPCFromHostedZoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4393,10 +4418,12 @@ const deserializeAws_restXmlDisassociateVPCFromHostedZoneCommandError = async ( throw await deserializeAws_restXmlVPCAssociationNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4429,8 +4456,7 @@ const deserializeAws_restXmlEnableHostedZoneDNSSECCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -4461,10 +4487,12 @@ const deserializeAws_restXmlEnableHostedZoneDNSSECCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4501,18 +4529,19 @@ const deserializeAws_restXmlGetAccountLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4545,8 +4574,7 @@ const deserializeAws_restXmlGetChangeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4556,10 +4584,12 @@ const deserializeAws_restXmlGetChangeCommandError = async ( throw await deserializeAws_restXmlNoSuchChangeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4597,15 +4627,16 @@ const deserializeAws_restXmlGetCheckerIpRangesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4647,8 +4678,7 @@ const deserializeAws_restXmlGetDNSSECCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArgument": case "com.amazonaws.route53#InvalidArgument": @@ -4661,10 +4691,12 @@ const deserializeAws_restXmlGetDNSSECCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4697,8 +4729,7 @@ const deserializeAws_restXmlGetGeoLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4708,10 +4739,12 @@ const deserializeAws_restXmlGetGeoLocationCommandError = async ( throw await deserializeAws_restXmlNoSuchGeoLocationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4744,8 +4777,7 @@ const deserializeAws_restXmlGetHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "IncompatibleVersion": case "com.amazonaws.route53#IncompatibleVersion": @@ -4758,10 +4790,12 @@ const deserializeAws_restXmlGetHealthCheckCommandError = async ( throw await deserializeAws_restXmlNoSuchHealthCheckResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4794,15 +4828,16 @@ const deserializeAws_restXmlGetHealthCheckCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4843,8 +4878,7 @@ const deserializeAws_restXmlGetHealthCheckLastFailureReasonCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4854,10 +4888,12 @@ const deserializeAws_restXmlGetHealthCheckLastFailureReasonCommandError = async throw await deserializeAws_restXmlNoSuchHealthCheckResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4898,8 +4934,7 @@ const deserializeAws_restXmlGetHealthCheckStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4909,10 +4944,12 @@ const deserializeAws_restXmlGetHealthCheckStatusCommandError = async ( throw await deserializeAws_restXmlNoSuchHealthCheckResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4955,8 +4992,7 @@ const deserializeAws_restXmlGetHostedZoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -4966,10 +5002,12 @@ const deserializeAws_restXmlGetHostedZoneCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5002,18 +5040,19 @@ const deserializeAws_restXmlGetHostedZoneCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5050,8 +5089,7 @@ const deserializeAws_restXmlGetHostedZoneLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "HostedZoneNotPrivate": case "com.amazonaws.route53#HostedZoneNotPrivate": @@ -5064,10 +5102,12 @@ const deserializeAws_restXmlGetHostedZoneLimitCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5100,8 +5140,7 @@ const deserializeAws_restXmlGetQueryLoggingConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5111,10 +5150,12 @@ const deserializeAws_restXmlGetQueryLoggingConfigCommandError = async ( throw await deserializeAws_restXmlNoSuchQueryLoggingConfigResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5147,8 +5188,7 @@ const deserializeAws_restXmlGetReusableDelegationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "DelegationSetNotReusable": case "com.amazonaws.route53#DelegationSetNotReusable": @@ -5161,10 +5201,12 @@ const deserializeAws_restXmlGetReusableDelegationSetCommandError = async ( throw await deserializeAws_restXmlNoSuchDelegationSetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5201,8 +5243,7 @@ const deserializeAws_restXmlGetReusableDelegationSetLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5212,10 +5253,12 @@ const deserializeAws_restXmlGetReusableDelegationSetLimitCommandError = async ( throw await deserializeAws_restXmlNoSuchDelegationSetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5248,8 +5291,7 @@ const deserializeAws_restXmlGetTrafficPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5259,10 +5301,12 @@ const deserializeAws_restXmlGetTrafficPolicyCommandError = async ( throw await deserializeAws_restXmlNoSuchTrafficPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5298,8 +5342,7 @@ const deserializeAws_restXmlGetTrafficPolicyInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5309,10 +5352,12 @@ const deserializeAws_restXmlGetTrafficPolicyInstanceCommandError = async ( throw await deserializeAws_restXmlNoSuchTrafficPolicyInstanceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5345,15 +5390,16 @@ const deserializeAws_restXmlGetTrafficPolicyInstanceCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5395,8 +5441,7 @@ const deserializeAws_restXmlListCidrBlocksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5409,10 +5454,12 @@ const deserializeAws_restXmlListCidrBlocksCommandError = async ( throw await deserializeAws_restXmlNoSuchCidrLocationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5454,18 +5501,19 @@ const deserializeAws_restXmlListCidrCollectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5507,8 +5555,7 @@ const deserializeAws_restXmlListCidrLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5518,10 +5565,12 @@ const deserializeAws_restXmlListCidrLocationsCommandError = async ( throw await deserializeAws_restXmlNoSuchCidrCollectionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5582,18 +5631,19 @@ const deserializeAws_restXmlListGeoLocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5647,8 +5697,7 @@ const deserializeAws_restXmlListHealthChecksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "IncompatibleVersion": case "com.amazonaws.route53#IncompatibleVersion": @@ -5658,10 +5707,12 @@ const deserializeAws_restXmlListHealthChecksCommandError = async ( throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5715,8 +5766,7 @@ const deserializeAws_restXmlListHostedZonesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "DelegationSetNotReusable": case "com.amazonaws.route53#DelegationSetNotReusable": @@ -5729,10 +5779,12 @@ const deserializeAws_restXmlListHostedZonesCommandError = async ( throw await deserializeAws_restXmlNoSuchDelegationSetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5794,8 +5846,7 @@ const deserializeAws_restXmlListHostedZonesByNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidDomainName": case "com.amazonaws.route53#InvalidDomainName": @@ -5805,10 +5856,12 @@ const deserializeAws_restXmlListHostedZonesByNameCommandError = async ( throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5857,8 +5910,7 @@ const deserializeAws_restXmlListHostedZonesByVPCCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5868,10 +5920,12 @@ const deserializeAws_restXmlListHostedZonesByVPCCommandError = async ( throw await deserializeAws_restXmlInvalidPaginationTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5916,8 +5970,7 @@ const deserializeAws_restXmlListQueryLoggingConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -5930,10 +5983,12 @@ const deserializeAws_restXmlListQueryLoggingConfigsCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5994,8 +6049,7 @@ const deserializeAws_restXmlListResourceRecordSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6005,10 +6059,12 @@ const deserializeAws_restXmlListResourceRecordSetsCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6062,18 +6118,19 @@ const deserializeAws_restXmlListReusableDelegationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6106,8 +6163,7 @@ const deserializeAws_restXmlListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6126,10 +6182,12 @@ const deserializeAws_restXmlListTagsForResourceCommandError = async ( throw await deserializeAws_restXmlThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6167,8 +6225,7 @@ const deserializeAws_restXmlListTagsForResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6187,10 +6244,12 @@ const deserializeAws_restXmlListTagsForResourcesCommandError = async ( throw await deserializeAws_restXmlThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6243,18 +6302,19 @@ const deserializeAws_restXmlListTrafficPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": throw await deserializeAws_restXmlInvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6315,8 +6375,7 @@ const deserializeAws_restXmlListTrafficPolicyInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6326,10 +6385,12 @@ const deserializeAws_restXmlListTrafficPolicyInstancesCommandError = async ( throw await deserializeAws_restXmlNoSuchTrafficPolicyInstanceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6386,8 +6447,7 @@ const deserializeAws_restXmlListTrafficPolicyInstancesByHostedZoneCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6400,10 +6460,12 @@ const deserializeAws_restXmlListTrafficPolicyInstancesByHostedZoneCommandError = throw await deserializeAws_restXmlNoSuchTrafficPolicyInstanceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6464,8 +6526,7 @@ const deserializeAws_restXmlListTrafficPolicyInstancesByPolicyCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6478,10 +6539,12 @@ const deserializeAws_restXmlListTrafficPolicyInstancesByPolicyCommandError = asy throw await deserializeAws_restXmlNoSuchTrafficPolicyInstanceResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6531,8 +6594,7 @@ const deserializeAws_restXmlListTrafficPolicyVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6542,10 +6604,12 @@ const deserializeAws_restXmlListTrafficPolicyVersionsCommandError = async ( throw await deserializeAws_restXmlNoSuchTrafficPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6588,8 +6652,7 @@ const deserializeAws_restXmlListVPCAssociationAuthorizationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6602,10 +6665,12 @@ const deserializeAws_restXmlListVPCAssociationAuthorizationsCommandError = async throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6663,8 +6728,7 @@ const deserializeAws_restXmlTestDNSAnswerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6674,10 +6738,12 @@ const deserializeAws_restXmlTestDNSAnswerCommandError = async ( throw await deserializeAws_restXmlNoSuchHostedZoneResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6710,8 +6776,7 @@ const deserializeAws_restXmlUpdateHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "HealthCheckVersionMismatch": case "com.amazonaws.route53#HealthCheckVersionMismatch": @@ -6724,10 +6789,12 @@ const deserializeAws_restXmlUpdateHealthCheckCommandError = async ( throw await deserializeAws_restXmlNoSuchHealthCheckResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6760,8 +6827,7 @@ const deserializeAws_restXmlUpdateHostedZoneCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.route53#InvalidInput": @@ -6774,10 +6840,12 @@ const deserializeAws_restXmlUpdateHostedZoneCommentCommandError = async ( throw await deserializeAws_restXmlPriorRequestNotCompleteResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6810,8 +6878,7 @@ const deserializeAws_restXmlUpdateTrafficPolicyCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModification": case "com.amazonaws.route53#ConcurrentModification": @@ -6824,10 +6891,12 @@ const deserializeAws_restXmlUpdateTrafficPolicyCommentCommandError = async ( throw await deserializeAws_restXmlNoSuchTrafficPolicyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -6863,8 +6932,7 @@ const deserializeAws_restXmlUpdateTrafficPolicyInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingTypes": case "com.amazonaws.route53#ConflictingTypes": @@ -6883,10 +6951,12 @@ const deserializeAws_restXmlUpdateTrafficPolicyInstanceCommandError = async ( throw await deserializeAws_restXmlPriorRequestNotCompleteResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9707,12 +9777,11 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => return {}; }); -const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-route53-recovery-cluster/src/protocols/Aws_json1_0.ts b/clients/client-route53-recovery-cluster/src/protocols/Aws_json1_0.ts index 33cee8b4fdb54..0a0504c9e6dc7 100644 --- a/clients/client-route53-recovery-cluster/src/protocols/Aws_json1_0.ts +++ b/clients/client-route53-recovery-cluster/src/protocols/Aws_json1_0.ts @@ -129,8 +129,7 @@ const deserializeAws_json1_0GetRoutingControlStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycluster#AccessDeniedException": @@ -152,10 +151,12 @@ const deserializeAws_json1_0GetRoutingControlStateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -187,8 +188,7 @@ const deserializeAws_json1_0ListRoutingControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycluster#AccessDeniedException": @@ -210,10 +210,12 @@ const deserializeAws_json1_0ListRoutingControlsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -245,8 +247,7 @@ const deserializeAws_json1_0UpdateRoutingControlStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycluster#AccessDeniedException": @@ -271,10 +272,12 @@ const deserializeAws_json1_0UpdateRoutingControlStateCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -306,8 +309,7 @@ const deserializeAws_json1_0UpdateRoutingControlStatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycluster#AccessDeniedException": @@ -335,10 +337,12 @@ const deserializeAws_json1_0UpdateRoutingControlStatesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -757,7 +761,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -783,6 +787,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-route53-recovery-control-config/src/protocols/Aws_restJson1.ts b/clients/client-route53-recovery-control-config/src/protocols/Aws_restJson1.ts index 4db0a584c3aa3..747c1edac3a08 100644 --- a/clients/client-route53-recovery-control-config/src/protocols/Aws_restJson1.ts +++ b/clients/client-route53-recovery-control-config/src/protocols/Aws_restJson1.ts @@ -793,8 +793,7 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -819,10 +818,12 @@ const deserializeAws_restJson1CreateClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -855,8 +856,7 @@ const deserializeAws_restJson1CreateControlPanelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -881,10 +881,12 @@ const deserializeAws_restJson1CreateControlPanelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -917,8 +919,7 @@ const deserializeAws_restJson1CreateRoutingControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -943,10 +944,12 @@ const deserializeAws_restJson1CreateRoutingControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -983,8 +986,7 @@ const deserializeAws_restJson1CreateSafetyRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -994,10 +996,12 @@ const deserializeAws_restJson1CreateSafetyRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1026,8 +1030,7 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1049,10 +1052,12 @@ const deserializeAws_restJson1DeleteClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1081,8 +1086,7 @@ const deserializeAws_restJson1DeleteControlPanelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1104,10 +1108,12 @@ const deserializeAws_restJson1DeleteControlPanelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1136,8 +1142,7 @@ const deserializeAws_restJson1DeleteRoutingControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1159,10 +1164,12 @@ const deserializeAws_restJson1DeleteRoutingControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1191,8 +1198,7 @@ const deserializeAws_restJson1DeleteSafetyRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -1205,10 +1211,12 @@ const deserializeAws_restJson1DeleteSafetyRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1241,8 +1249,7 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1264,10 +1271,12 @@ const deserializeAws_restJson1DescribeClusterCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1309,7 @@ const deserializeAws_restJson1DescribeControlPanelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1323,10 +1331,12 @@ const deserializeAws_restJson1DescribeControlPanelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1359,8 +1369,7 @@ const deserializeAws_restJson1DescribeRoutingControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1382,10 +1391,12 @@ const deserializeAws_restJson1DescribeRoutingControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1422,8 +1433,7 @@ const deserializeAws_restJson1DescribeSafetyRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.route53recoverycontrolconfig#ResourceNotFoundException": @@ -1433,10 +1443,12 @@ const deserializeAws_restJson1DescribeSafetyRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1473,8 +1485,7 @@ const deserializeAws_restJson1ListAssociatedRoute53HealthChecksCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -1487,10 +1498,12 @@ const deserializeAws_restJson1ListAssociatedRoute53HealthChecksCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1527,8 +1540,7 @@ const deserializeAws_restJson1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1547,10 +1559,12 @@ const deserializeAws_restJson1ListClustersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1587,8 +1601,7 @@ const deserializeAws_restJson1ListControlPanelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1607,10 +1620,12 @@ const deserializeAws_restJson1ListControlPanelsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1647,8 +1662,7 @@ const deserializeAws_restJson1ListRoutingControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1667,10 +1681,12 @@ const deserializeAws_restJson1ListRoutingControlsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1707,8 +1723,7 @@ const deserializeAws_restJson1ListSafetyRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1727,10 +1742,12 @@ const deserializeAws_restJson1ListSafetyRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1763,8 +1780,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -1777,10 +1793,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1809,8 +1827,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -1823,10 +1840,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1855,8 +1874,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -1869,10 +1887,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1905,8 +1925,7 @@ const deserializeAws_restJson1UpdateControlPanelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1928,10 +1947,12 @@ const deserializeAws_restJson1UpdateControlPanelCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1964,8 +1985,7 @@ const deserializeAws_restJson1UpdateRoutingControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoverycontrolconfig#AccessDeniedException": @@ -1987,10 +2007,12 @@ const deserializeAws_restJson1UpdateRoutingControlCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2027,8 +2049,7 @@ const deserializeAws_restJson1UpdateSafetyRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoverycontrolconfig#InternalServerException": @@ -2041,10 +2062,12 @@ const deserializeAws_restJson1UpdateSafetyRuleCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2491,7 +2514,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2517,6 +2540,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-route53-recovery-readiness/src/protocols/Aws_restJson1.ts b/clients/client-route53-recovery-readiness/src/protocols/Aws_restJson1.ts index 79aae37196fd9..bc7ed2d403443 100644 --- a/clients/client-route53-recovery-readiness/src/protocols/Aws_restJson1.ts +++ b/clients/client-route53-recovery-readiness/src/protocols/Aws_restJson1.ts @@ -1124,8 +1124,7 @@ const deserializeAws_restJson1CreateCellCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1144,10 +1143,12 @@ const deserializeAws_restJson1CreateCellCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1180,8 +1181,7 @@ const deserializeAws_restJson1CreateCrossAccountAuthorizationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1200,10 +1200,12 @@ const deserializeAws_restJson1CreateCrossAccountAuthorizationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1248,8 +1250,7 @@ const deserializeAws_restJson1CreateReadinessCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1268,10 +1269,12 @@ const deserializeAws_restJson1CreateReadinessCheckCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1316,8 +1319,7 @@ const deserializeAws_restJson1CreateRecoveryGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1336,10 +1338,12 @@ const deserializeAws_restJson1CreateRecoveryGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1388,8 +1392,7 @@ const deserializeAws_restJson1CreateResourceSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1408,10 +1411,12 @@ const deserializeAws_restJson1CreateResourceSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1440,8 +1445,7 @@ const deserializeAws_restJson1DeleteCellCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1460,10 +1464,12 @@ const deserializeAws_restJson1DeleteCellCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1492,8 +1498,7 @@ const deserializeAws_restJson1DeleteCrossAccountAuthorizationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1509,10 +1514,12 @@ const deserializeAws_restJson1DeleteCrossAccountAuthorizationCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1541,8 +1548,7 @@ const deserializeAws_restJson1DeleteReadinessCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1561,10 +1567,12 @@ const deserializeAws_restJson1DeleteReadinessCheckCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1593,8 +1601,7 @@ const deserializeAws_restJson1DeleteRecoveryGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1613,10 +1620,12 @@ const deserializeAws_restJson1DeleteRecoveryGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1645,8 +1654,7 @@ const deserializeAws_restJson1DeleteResourceSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1665,10 +1673,12 @@ const deserializeAws_restJson1DeleteResourceSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1709,8 +1719,7 @@ const deserializeAws_restJson1GetArchitectureRecommendationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1729,10 +1738,12 @@ const deserializeAws_restJson1GetArchitectureRecommendationsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1781,8 +1792,7 @@ const deserializeAws_restJson1GetCellCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1801,10 +1811,12 @@ const deserializeAws_restJson1GetCellCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1845,8 +1857,7 @@ const deserializeAws_restJson1GetCellReadinessSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1865,10 +1876,12 @@ const deserializeAws_restJson1GetCellReadinessSummaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1926,7 @@ const deserializeAws_restJson1GetReadinessCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1933,10 +1945,12 @@ const deserializeAws_restJson1GetReadinessCheckCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1991,7 @@ const deserializeAws_restJson1GetReadinessCheckResourceStatusCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -1997,10 +2010,12 @@ const deserializeAws_restJson1GetReadinessCheckResourceStatusCommandError = asyn throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2060,7 @@ const deserializeAws_restJson1GetReadinessCheckStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2065,10 +2079,12 @@ const deserializeAws_restJson1GetReadinessCheckStatusCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2113,8 +2129,7 @@ const deserializeAws_restJson1GetRecoveryGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2133,10 +2148,12 @@ const deserializeAws_restJson1GetRecoveryGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2177,8 +2194,7 @@ const deserializeAws_restJson1GetRecoveryGroupReadinessSummaryCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2197,10 +2213,12 @@ const deserializeAws_restJson1GetRecoveryGroupReadinessSummaryCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2249,8 +2267,7 @@ const deserializeAws_restJson1GetResourceSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2269,10 +2286,12 @@ const deserializeAws_restJson1GetResourceSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2309,8 +2328,7 @@ const deserializeAws_restJson1ListCellsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2326,10 +2344,12 @@ const deserializeAws_restJson1ListCellsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2369,8 +2389,7 @@ const deserializeAws_restJson1ListCrossAccountAuthorizationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2386,10 +2405,12 @@ const deserializeAws_restJson1ListCrossAccountAuthorizationsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2426,8 +2447,7 @@ const deserializeAws_restJson1ListReadinessChecksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2443,10 +2463,12 @@ const deserializeAws_restJson1ListReadinessChecksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2483,8 +2505,7 @@ const deserializeAws_restJson1ListRecoveryGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2500,10 +2521,12 @@ const deserializeAws_restJson1ListRecoveryGroupsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2540,8 +2563,7 @@ const deserializeAws_restJson1ListResourceSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2557,10 +2579,12 @@ const deserializeAws_restJson1ListResourceSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2597,8 +2621,7 @@ const deserializeAws_restJson1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2614,10 +2637,12 @@ const deserializeAws_restJson1ListRulesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2650,8 +2675,7 @@ const deserializeAws_restJson1ListTagsForResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoveryreadiness#InternalServerException": @@ -2664,10 +2688,12 @@ const deserializeAws_restJson1ListTagsForResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2696,8 +2722,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoveryreadiness#InternalServerException": @@ -2710,10 +2735,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2742,8 +2769,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.route53recoveryreadiness#InternalServerException": @@ -2756,10 +2782,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2808,8 +2836,7 @@ const deserializeAws_restJson1UpdateCellCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2828,10 +2855,12 @@ const deserializeAws_restJson1UpdateCellCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2876,8 +2905,7 @@ const deserializeAws_restJson1UpdateReadinessCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2896,10 +2924,12 @@ const deserializeAws_restJson1UpdateReadinessCheckCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2944,8 +2974,7 @@ const deserializeAws_restJson1UpdateRecoveryGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -2964,10 +2993,12 @@ const deserializeAws_restJson1UpdateRecoveryGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3016,8 +3047,7 @@ const deserializeAws_restJson1UpdateResourceSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53recoveryreadiness#AccessDeniedException": @@ -3036,10 +3066,12 @@ const deserializeAws_restJson1UpdateResourceSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3614,7 +3646,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3640,6 +3672,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-route53resolver/src/protocols/Aws_json1_1.ts b/clients/client-route53resolver/src/protocols/Aws_json1_1.ts index 2e3de0fe8379e..170cc7569ea1b 100644 --- a/clients/client-route53resolver/src/protocols/Aws_json1_1.ts +++ b/clients/client-route53resolver/src/protocols/Aws_json1_1.ts @@ -1239,8 +1239,7 @@ const deserializeAws_json1_1AssociateFirewallRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1265,10 +1264,12 @@ const deserializeAws_json1_1AssociateFirewallRuleGroupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1301,7 @@ const deserializeAws_json1_1AssociateResolverEndpointIpAddressCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -1326,10 +1326,12 @@ const deserializeAws_json1_1AssociateResolverEndpointIpAddressCommandError = asy throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1361,8 +1363,7 @@ const deserializeAws_json1_1AssociateResolverQueryLogConfigCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1390,10 +1391,12 @@ const deserializeAws_json1_1AssociateResolverQueryLogConfigCommandError = async throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1425,8 +1428,7 @@ const deserializeAws_json1_1AssociateResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -1454,10 +1456,12 @@ const deserializeAws_json1_1AssociateResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1489,8 +1493,7 @@ const deserializeAws_json1_1CreateFirewallDomainListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1509,10 +1512,12 @@ const deserializeAws_json1_1CreateFirewallDomainListCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1544,8 +1549,7 @@ const deserializeAws_json1_1CreateFirewallRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1567,10 +1571,12 @@ const deserializeAws_json1_1CreateFirewallRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1602,8 +1608,7 @@ const deserializeAws_json1_1CreateFirewallRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1622,10 +1627,12 @@ const deserializeAws_json1_1CreateFirewallRuleGroupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1657,8 +1664,7 @@ const deserializeAws_json1_1CreateResolverEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -1683,10 +1689,12 @@ const deserializeAws_json1_1CreateResolverEndpointCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1718,8 +1726,7 @@ const deserializeAws_json1_1CreateResolverQueryLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1747,10 +1754,12 @@ const deserializeAws_json1_1CreateResolverQueryLogConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1782,8 +1791,7 @@ const deserializeAws_json1_1CreateResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -1811,10 +1819,12 @@ const deserializeAws_json1_1CreateResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1846,8 +1856,7 @@ const deserializeAws_json1_1DeleteFirewallDomainListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1866,10 +1875,12 @@ const deserializeAws_json1_1DeleteFirewallDomainListCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1901,8 +1912,7 @@ const deserializeAws_json1_1DeleteFirewallRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1918,10 +1928,12 @@ const deserializeAws_json1_1DeleteFirewallRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1953,8 +1965,7 @@ const deserializeAws_json1_1DeleteFirewallRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -1976,10 +1987,12 @@ const deserializeAws_json1_1DeleteFirewallRuleGroupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2011,8 +2024,7 @@ const deserializeAws_json1_1DeleteResolverEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -2031,10 +2043,12 @@ const deserializeAws_json1_1DeleteResolverEndpointCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2066,8 +2080,7 @@ const deserializeAws_json1_1DeleteResolverQueryLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2089,10 +2102,12 @@ const deserializeAws_json1_1DeleteResolverQueryLogConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2124,8 +2139,7 @@ const deserializeAws_json1_1DeleteResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -2144,10 +2158,12 @@ const deserializeAws_json1_1DeleteResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2179,8 +2195,7 @@ const deserializeAws_json1_1DisassociateFirewallRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2202,10 +2217,12 @@ const deserializeAws_json1_1DisassociateFirewallRuleGroupCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2237,8 +2254,7 @@ const deserializeAws_json1_1DisassociateResolverEndpointIpAddressCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -2260,10 +2276,12 @@ const deserializeAws_json1_1DisassociateResolverEndpointIpAddressCommandError = throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2295,8 +2313,7 @@ const deserializeAws_json1_1DisassociateResolverQueryLogConfigCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2318,10 +2335,12 @@ const deserializeAws_json1_1DisassociateResolverQueryLogConfigCommandError = asy throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2353,8 +2372,7 @@ const deserializeAws_json1_1DisassociateResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -2370,10 +2388,12 @@ const deserializeAws_json1_1DisassociateResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2405,8 +2425,7 @@ const deserializeAws_json1_1GetFirewallConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2425,10 +2444,12 @@ const deserializeAws_json1_1GetFirewallConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2460,8 +2481,7 @@ const deserializeAws_json1_1GetFirewallDomainListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2477,10 +2497,12 @@ const deserializeAws_json1_1GetFirewallDomainListCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2512,8 +2534,7 @@ const deserializeAws_json1_1GetFirewallRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2529,10 +2550,12 @@ const deserializeAws_json1_1GetFirewallRuleGroupCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2564,8 +2587,7 @@ const deserializeAws_json1_1GetFirewallRuleGroupAssociationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2581,10 +2603,12 @@ const deserializeAws_json1_1GetFirewallRuleGroupAssociationCommandError = async throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2616,8 +2640,7 @@ const deserializeAws_json1_1GetFirewallRuleGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2636,10 +2659,12 @@ const deserializeAws_json1_1GetFirewallRuleGroupPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2671,8 +2696,7 @@ const deserializeAws_json1_1GetResolverConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2691,10 +2715,12 @@ const deserializeAws_json1_1GetResolverConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2726,8 +2752,7 @@ const deserializeAws_json1_1GetResolverDnssecConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2749,10 +2774,12 @@ const deserializeAws_json1_1GetResolverDnssecConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2784,8 +2811,7 @@ const deserializeAws_json1_1GetResolverEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -2801,10 +2827,12 @@ const deserializeAws_json1_1GetResolverEndpointCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2836,8 +2864,7 @@ const deserializeAws_json1_1GetResolverQueryLogConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2859,10 +2886,12 @@ const deserializeAws_json1_1GetResolverQueryLogConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2894,8 +2923,7 @@ const deserializeAws_json1_1GetResolverQueryLogConfigAssociationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2917,10 +2945,12 @@ const deserializeAws_json1_1GetResolverQueryLogConfigAssociationCommandError = a throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2952,8 +2982,7 @@ const deserializeAws_json1_1GetResolverQueryLogConfigPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -2972,10 +3001,12 @@ const deserializeAws_json1_1GetResolverQueryLogConfigPolicyCommandError = async throw await deserializeAws_json1_1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3007,8 +3038,7 @@ const deserializeAws_json1_1GetResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3024,10 +3054,12 @@ const deserializeAws_json1_1GetResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3059,8 +3091,7 @@ const deserializeAws_json1_1GetResolverRuleAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3076,10 +3107,12 @@ const deserializeAws_json1_1GetResolverRuleAssociationCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3111,8 +3144,7 @@ const deserializeAws_json1_1GetResolverRulePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3125,10 +3157,12 @@ const deserializeAws_json1_1GetResolverRulePolicyCommandError = async ( throw await deserializeAws_json1_1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3160,8 +3194,7 @@ const deserializeAws_json1_1ImportFirewallDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3186,10 +3219,12 @@ const deserializeAws_json1_1ImportFirewallDomainsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3221,8 +3256,7 @@ const deserializeAws_json1_1ListFirewallConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3238,10 +3272,12 @@ const deserializeAws_json1_1ListFirewallConfigsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3273,8 +3309,7 @@ const deserializeAws_json1_1ListFirewallDomainListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3290,10 +3325,12 @@ const deserializeAws_json1_1ListFirewallDomainListsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3325,8 +3362,7 @@ const deserializeAws_json1_1ListFirewallDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3345,10 +3381,12 @@ const deserializeAws_json1_1ListFirewallDomainsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3380,8 +3418,7 @@ const deserializeAws_json1_1ListFirewallRuleGroupAssociationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3397,10 +3434,12 @@ const deserializeAws_json1_1ListFirewallRuleGroupAssociationsCommandError = asyn throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3432,8 +3471,7 @@ const deserializeAws_json1_1ListFirewallRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3449,10 +3487,12 @@ const deserializeAws_json1_1ListFirewallRuleGroupsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3484,8 +3524,7 @@ const deserializeAws_json1_1ListFirewallRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3504,10 +3543,12 @@ const deserializeAws_json1_1ListFirewallRulesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3539,8 +3580,7 @@ const deserializeAws_json1_1ListResolverConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3562,10 +3602,12 @@ const deserializeAws_json1_1ListResolverConfigsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3597,8 +3639,7 @@ const deserializeAws_json1_1ListResolverDnssecConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3620,10 +3661,12 @@ const deserializeAws_json1_1ListResolverDnssecConfigsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3655,8 +3698,7 @@ const deserializeAws_json1_1ListResolverEndpointIpAddressesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3675,10 +3717,12 @@ const deserializeAws_json1_1ListResolverEndpointIpAddressesCommandError = async throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3710,8 +3754,7 @@ const deserializeAws_json1_1ListResolverEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3730,10 +3773,12 @@ const deserializeAws_json1_1ListResolverEndpointsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3765,8 +3810,7 @@ const deserializeAws_json1_1ListResolverQueryLogConfigAssociationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3788,10 +3832,12 @@ const deserializeAws_json1_1ListResolverQueryLogConfigAssociationsCommandError = throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3823,8 +3869,7 @@ const deserializeAws_json1_1ListResolverQueryLogConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -3846,10 +3891,12 @@ const deserializeAws_json1_1ListResolverQueryLogConfigsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3881,8 +3928,7 @@ const deserializeAws_json1_1ListResolverRuleAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3901,10 +3947,12 @@ const deserializeAws_json1_1ListResolverRuleAssociationsCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3936,8 +3984,7 @@ const deserializeAws_json1_1ListResolverRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -3956,10 +4003,12 @@ const deserializeAws_json1_1ListResolverRulesCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3991,8 +4040,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4014,10 +4062,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4049,8 +4099,7 @@ const deserializeAws_json1_1PutFirewallRuleGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4069,10 +4118,12 @@ const deserializeAws_json1_1PutFirewallRuleGroupPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4104,8 +4155,7 @@ const deserializeAws_json1_1PutResolverQueryLogConfigPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4127,10 +4177,12 @@ const deserializeAws_json1_1PutResolverQueryLogConfigPolicyCommandError = async throw await deserializeAws_json1_1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4162,8 +4214,7 @@ const deserializeAws_json1_1PutResolverRulePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4179,10 +4230,12 @@ const deserializeAws_json1_1PutResolverRulePolicyCommandError = async ( throw await deserializeAws_json1_1UnknownResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4214,8 +4267,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4240,10 +4292,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4275,8 +4329,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4295,10 +4348,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4330,8 +4385,7 @@ const deserializeAws_json1_1UpdateFirewallConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4350,10 +4404,12 @@ const deserializeAws_json1_1UpdateFirewallConfigCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4385,8 +4441,7 @@ const deserializeAws_json1_1UpdateFirewallDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4411,10 +4466,12 @@ const deserializeAws_json1_1UpdateFirewallDomainsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4446,8 +4503,7 @@ const deserializeAws_json1_1UpdateFirewallRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4469,10 +4525,12 @@ const deserializeAws_json1_1UpdateFirewallRuleCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4504,8 +4562,7 @@ const deserializeAws_json1_1UpdateFirewallRuleGroupAssociationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4527,10 +4584,12 @@ const deserializeAws_json1_1UpdateFirewallRuleGroupAssociationCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4562,8 +4621,7 @@ const deserializeAws_json1_1UpdateResolverConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4591,10 +4649,12 @@ const deserializeAws_json1_1UpdateResolverConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4626,8 +4686,7 @@ const deserializeAws_json1_1UpdateResolverDnssecConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.route53resolver#AccessDeniedException": @@ -4649,10 +4708,12 @@ const deserializeAws_json1_1UpdateResolverDnssecConfigCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4684,8 +4745,7 @@ const deserializeAws_json1_1UpdateResolverEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4704,10 +4764,12 @@ const deserializeAws_json1_1UpdateResolverEndpointCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4739,8 +4801,7 @@ const deserializeAws_json1_1UpdateResolverRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceErrorException": case "com.amazonaws.route53resolver#InternalServiceErrorException": @@ -4765,10 +4826,12 @@ const deserializeAws_json1_1UpdateResolverRuleCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7246,7 +7309,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7272,6 +7335,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-rum/src/protocols/Aws_restJson1.ts b/clients/client-rum/src/protocols/Aws_restJson1.ts index 84dec3227778c..3228a20763f69 100644 --- a/clients/client-rum/src/protocols/Aws_restJson1.ts +++ b/clients/client-rum/src/protocols/Aws_restJson1.ts @@ -412,8 +412,7 @@ const deserializeAws_restJson1CreateAppMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -435,10 +434,12 @@ const deserializeAws_restJson1CreateAppMonitorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -467,8 +468,7 @@ const deserializeAws_restJson1DeleteAppMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -490,10 +490,12 @@ const deserializeAws_restJson1DeleteAppMonitorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -526,8 +528,7 @@ const deserializeAws_restJson1GetAppMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -546,10 +547,12 @@ const deserializeAws_restJson1GetAppMonitorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -586,8 +589,7 @@ const deserializeAws_restJson1GetAppMonitorDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -606,10 +608,12 @@ const deserializeAws_restJson1GetAppMonitorDataCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -646,8 +650,7 @@ const deserializeAws_restJson1ListAppMonitorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -663,10 +666,12 @@ const deserializeAws_restJson1ListAppMonitorsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -703,8 +708,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rum#InternalServerException": @@ -717,10 +721,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -749,8 +755,7 @@ const deserializeAws_restJson1PutRumEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -769,10 +774,12 @@ const deserializeAws_restJson1PutRumEventsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -801,8 +808,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rum#InternalServerException": @@ -815,10 +821,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -847,8 +855,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.rum#InternalServerException": @@ -861,10 +868,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -893,8 +902,7 @@ const deserializeAws_restJson1UpdateAppMonitorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.rum#AccessDeniedException": @@ -916,10 +924,12 @@ const deserializeAws_restJson1UpdateAppMonitorCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1394,7 +1404,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1420,6 +1430,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-s3-control/src/protocols/Aws_restXml.ts b/clients/client-s3-control/src/protocols/Aws_restXml.ts index be98d4405c1c3..2b2e34b88e3dc 100644 --- a/clients/client-s3-control/src/protocols/Aws_restXml.ts +++ b/clients/client-s3-control/src/protocols/Aws_restXml.ts @@ -2943,15 +2943,16 @@ const deserializeAws_restXmlCreateAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2984,15 +2985,16 @@ const deserializeAws_restXmlCreateAccessPointForObjectLambdaCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3029,8 +3031,7 @@ const deserializeAws_restXmlCreateBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BucketAlreadyExists": case "com.amazonaws.s3control#BucketAlreadyExists": @@ -3040,10 +3041,12 @@ const deserializeAws_restXmlCreateBucketCommandError = async ( throw await deserializeAws_restXmlBucketAlreadyOwnedByYouResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3076,8 +3079,7 @@ const deserializeAws_restXmlCreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.s3control#BadRequestException": @@ -3093,10 +3095,12 @@ const deserializeAws_restXmlCreateJobCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3129,15 +3133,16 @@ const deserializeAws_restXmlCreateMultiRegionAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3166,15 +3171,16 @@ const deserializeAws_restXmlDeleteAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3203,15 +3209,16 @@ const deserializeAws_restXmlDeleteAccessPointForObjectLambdaCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3240,15 +3247,16 @@ const deserializeAws_restXmlDeleteAccessPointPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3277,15 +3285,16 @@ const deserializeAws_restXmlDeleteAccessPointPolicyForObjectLambdaCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3314,15 +3323,16 @@ const deserializeAws_restXmlDeleteBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3351,15 +3361,16 @@ const deserializeAws_restXmlDeleteBucketLifecycleConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3388,15 +3399,16 @@ const deserializeAws_restXmlDeleteBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3425,15 +3437,16 @@ const deserializeAws_restXmlDeleteBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3462,8 +3475,7 @@ const deserializeAws_restXmlDeleteJobTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.s3control#InternalServiceException": @@ -3476,10 +3488,12 @@ const deserializeAws_restXmlDeleteJobTaggingCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3512,15 +3526,16 @@ const deserializeAws_restXmlDeleteMultiRegionAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3549,15 +3564,16 @@ const deserializeAws_restXmlDeletePublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3586,15 +3602,16 @@ const deserializeAws_restXmlDeleteStorageLensConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3623,15 +3640,16 @@ const deserializeAws_restXmlDeleteStorageLensConfigurationTaggingCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3664,8 +3682,7 @@ const deserializeAws_restXmlDescribeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.s3control#BadRequestException": @@ -3681,10 +3698,12 @@ const deserializeAws_restXmlDescribeJobCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3717,15 +3736,16 @@ const deserializeAws_restXmlDescribeMultiRegionAccessPointOperationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3795,15 +3815,16 @@ const deserializeAws_restXmlGetAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3836,15 +3857,16 @@ const deserializeAws_restXmlGetAccessPointConfigurationForObjectLambdaCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3888,15 +3910,16 @@ const deserializeAws_restXmlGetAccessPointForObjectLambdaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3929,15 +3952,16 @@ const deserializeAws_restXmlGetAccessPointPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3970,15 +3994,16 @@ const deserializeAws_restXmlGetAccessPointPolicyForObjectLambdaCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4011,15 +4036,16 @@ const deserializeAws_restXmlGetAccessPointPolicyStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4052,15 +4078,16 @@ const deserializeAws_restXmlGetAccessPointPolicyStatusForObjectLambdaCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4101,15 +4128,16 @@ const deserializeAws_restXmlGetBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4144,15 +4172,16 @@ const deserializeAws_restXmlGetBucketLifecycleConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4185,15 +4214,16 @@ const deserializeAws_restXmlGetBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4228,15 +4258,16 @@ const deserializeAws_restXmlGetBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4271,8 +4302,7 @@ const deserializeAws_restXmlGetJobTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.s3control#InternalServiceException": @@ -4285,10 +4315,12 @@ const deserializeAws_restXmlGetJobTaggingCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4321,15 +4353,16 @@ const deserializeAws_restXmlGetMultiRegionAccessPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4362,15 +4395,16 @@ const deserializeAws_restXmlGetMultiRegionAccessPointPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4403,15 +4437,16 @@ const deserializeAws_restXmlGetMultiRegionAccessPointPolicyStatusCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4442,18 +4477,19 @@ const deserializeAws_restXmlGetPublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchPublicAccessBlockConfiguration": case "com.amazonaws.s3control#NoSuchPublicAccessBlockConfiguration": throw await deserializeAws_restXmlNoSuchPublicAccessBlockConfigurationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4484,15 +4520,16 @@ const deserializeAws_restXmlGetStorageLensConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4527,15 +4564,16 @@ const deserializeAws_restXmlGetStorageLensConfigurationTaggingCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4577,15 +4615,16 @@ const deserializeAws_restXmlListAccessPointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4630,15 +4669,16 @@ const deserializeAws_restXmlListAccessPointsForObjectLambdaCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4680,8 +4720,7 @@ const deserializeAws_restXmlListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.s3control#InternalServiceException": @@ -4694,10 +4733,12 @@ const deserializeAws_restXmlListJobsCommandError = async ( throw await deserializeAws_restXmlInvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4739,15 +4780,16 @@ const deserializeAws_restXmlListMultiRegionAccessPointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4789,15 +4831,16 @@ const deserializeAws_restXmlListRegionalBucketsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4839,15 +4882,16 @@ const deserializeAws_restXmlListStorageLensConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4876,15 +4920,16 @@ const deserializeAws_restXmlPutAccessPointConfigurationForObjectLambdaCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4913,15 +4958,16 @@ const deserializeAws_restXmlPutAccessPointPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4950,15 +4996,16 @@ const deserializeAws_restXmlPutAccessPointPolicyForObjectLambdaCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4987,15 +5034,16 @@ const deserializeAws_restXmlPutBucketLifecycleConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5024,15 +5072,16 @@ const deserializeAws_restXmlPutBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5061,15 +5110,16 @@ const deserializeAws_restXmlPutBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5098,8 +5148,7 @@ const deserializeAws_restXmlPutJobTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.s3control#InternalServiceException": @@ -5115,10 +5164,12 @@ const deserializeAws_restXmlPutJobTaggingCommandError = async ( throw await deserializeAws_restXmlTooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5151,15 +5202,16 @@ const deserializeAws_restXmlPutMultiRegionAccessPointPolicyCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5188,15 +5240,16 @@ const deserializeAws_restXmlPutPublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5225,15 +5278,16 @@ const deserializeAws_restXmlPutStorageLensConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5262,15 +5316,16 @@ const deserializeAws_restXmlPutStorageLensConfigurationTaggingCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5307,8 +5362,7 @@ const deserializeAws_restXmlUpdateJobPriorityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.s3control#BadRequestException": @@ -5324,10 +5378,12 @@ const deserializeAws_restXmlUpdateJobPriorityCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5368,8 +5424,7 @@ const deserializeAws_restXmlUpdateJobStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.s3control#BadRequestException": @@ -5388,10 +5443,12 @@ const deserializeAws_restXmlUpdateJobStatusCommandError = async ( throw await deserializeAws_restXmlTooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9330,12 +9387,11 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => return {}; }); -const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-s3/src/protocols/Aws_restXml.ts b/clients/client-s3/src/protocols/Aws_restXml.ts index 4b2af5c743ee9..1c80c34a404e9 100644 --- a/clients/client-s3/src/protocols/Aws_restXml.ts +++ b/clients/client-s3/src/protocols/Aws_restXml.ts @@ -5155,18 +5155,19 @@ const deserializeAws_restXmlAbortMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchUpload": case "com.amazonaws.s3#NoSuchUpload": throw await deserializeAws_restXmlNoSuchUploadResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5251,15 +5252,16 @@ const deserializeAws_restXmlCompleteMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5330,18 +5332,19 @@ const deserializeAws_restXmlCopyObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ObjectNotInActiveTierError": case "com.amazonaws.s3#ObjectNotInActiveTierError": throw await deserializeAws_restXmlObjectNotInActiveTierErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5374,8 +5377,7 @@ const deserializeAws_restXmlCreateBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "BucketAlreadyExists": case "com.amazonaws.s3#BucketAlreadyExists": @@ -5385,10 +5387,12 @@ const deserializeAws_restXmlCreateBucketCommandError = async ( throw await deserializeAws_restXmlBucketAlreadyOwnedByYouResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5469,15 +5473,16 @@ const deserializeAws_restXmlCreateMultipartUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5506,15 +5511,16 @@ const deserializeAws_restXmlDeleteBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5543,15 +5549,16 @@ const deserializeAws_restXmlDeleteBucketAnalyticsConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5580,15 +5587,16 @@ const deserializeAws_restXmlDeleteBucketCorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5617,15 +5625,16 @@ const deserializeAws_restXmlDeleteBucketEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5654,15 +5663,16 @@ const deserializeAws_restXmlDeleteBucketIntelligentTieringConfigurationCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5691,15 +5701,16 @@ const deserializeAws_restXmlDeleteBucketInventoryConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5728,15 +5739,16 @@ const deserializeAws_restXmlDeleteBucketLifecycleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5765,15 +5777,16 @@ const deserializeAws_restXmlDeleteBucketMetricsConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5802,15 +5815,16 @@ const deserializeAws_restXmlDeleteBucketOwnershipControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5839,15 +5853,16 @@ const deserializeAws_restXmlDeleteBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5876,15 +5891,16 @@ const deserializeAws_restXmlDeleteBucketReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5913,15 +5929,16 @@ const deserializeAws_restXmlDeleteBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5950,15 +5967,16 @@ const deserializeAws_restXmlDeleteBucketWebsiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5999,15 +6017,16 @@ const deserializeAws_restXmlDeleteObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6052,15 +6071,16 @@ const deserializeAws_restXmlDeleteObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6093,15 +6113,16 @@ const deserializeAws_restXmlDeleteObjectTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6130,15 +6151,16 @@ const deserializeAws_restXmlDeletePublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6171,15 +6193,16 @@ const deserializeAws_restXmlGetBucketAccelerateConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6218,15 +6241,16 @@ const deserializeAws_restXmlGetBucketAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6257,15 +6281,16 @@ const deserializeAws_restXmlGetBucketAnalyticsConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6300,15 +6325,16 @@ const deserializeAws_restXmlGetBucketCorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6339,15 +6365,16 @@ const deserializeAws_restXmlGetBucketEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6378,15 +6405,16 @@ const deserializeAws_restXmlGetBucketIntelligentTieringConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6417,15 +6445,16 @@ const deserializeAws_restXmlGetBucketInventoryConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6460,15 +6489,16 @@ const deserializeAws_restXmlGetBucketLifecycleConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6501,15 +6531,16 @@ const deserializeAws_restXmlGetBucketLocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6542,15 +6573,16 @@ const deserializeAws_restXmlGetBucketLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6581,15 +6613,16 @@ const deserializeAws_restXmlGetBucketMetricsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6652,15 +6685,16 @@ const deserializeAws_restXmlGetBucketNotificationConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6691,15 +6725,16 @@ const deserializeAws_restXmlGetBucketOwnershipControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6730,15 +6765,16 @@ const deserializeAws_restXmlGetBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6769,15 +6805,16 @@ const deserializeAws_restXmlGetBucketPolicyStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6808,15 +6845,16 @@ const deserializeAws_restXmlGetBucketReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6849,15 +6887,16 @@ const deserializeAws_restXmlGetBucketRequestPaymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6892,15 +6931,16 @@ const deserializeAws_restXmlGetBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6937,15 +6977,16 @@ const deserializeAws_restXmlGetBucketVersioningCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6998,15 +7039,16 @@ const deserializeAws_restXmlGetBucketWebsiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7184,8 +7226,7 @@ const deserializeAws_restXmlGetObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidObjectState": case "com.amazonaws.s3#InvalidObjectState": @@ -7195,10 +7236,12 @@ const deserializeAws_restXmlGetObjectCommandError = async ( throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7241,18 +7284,19 @@ const deserializeAws_restXmlGetObjectAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchKey": case "com.amazonaws.s3#NoSuchKey": throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7317,18 +7361,19 @@ const deserializeAws_restXmlGetObjectAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchKey": case "com.amazonaws.s3#NoSuchKey": throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7359,15 +7404,16 @@ const deserializeAws_restXmlGetObjectLegalHoldCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7398,15 +7444,16 @@ const deserializeAws_restXmlGetObjectLockConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7437,15 +7484,16 @@ const deserializeAws_restXmlGetObjectRetentionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7484,15 +7532,16 @@ const deserializeAws_restXmlGetObjectTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7527,15 +7576,16 @@ const deserializeAws_restXmlGetObjectTorrentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7566,15 +7616,16 @@ const deserializeAws_restXmlGetPublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7603,18 +7654,19 @@ const deserializeAws_restXmlHeadBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFound": case "com.amazonaws.s3#NotFound": throw await deserializeAws_restXmlNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7786,18 +7838,19 @@ const deserializeAws_restXmlHeadObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NotFound": case "com.amazonaws.s3#NotFound": throw await deserializeAws_restXmlNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7847,15 +7900,16 @@ const deserializeAws_restXmlListBucketAnalyticsConfigurationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7905,15 +7959,16 @@ const deserializeAws_restXmlListBucketIntelligentTieringConfigurationsCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7963,15 +8018,16 @@ const deserializeAws_restXmlListBucketInventoryConfigurationsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8021,15 +8077,16 @@ const deserializeAws_restXmlListBucketMetricsConfigurationsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8068,15 +8125,16 @@ const deserializeAws_restXmlListBucketsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8160,15 +8218,16 @@ const deserializeAws_restXmlListMultipartUploadsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8244,18 +8303,19 @@ const deserializeAws_restXmlListObjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchBucket": case "com.amazonaws.s3#NoSuchBucket": throw await deserializeAws_restXmlNoSuchBucketResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8339,18 +8399,19 @@ const deserializeAws_restXmlListObjectsV2CommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchBucket": case "com.amazonaws.s3#NoSuchBucket": throw await deserializeAws_restXmlNoSuchBucketResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8440,15 +8501,16 @@ const deserializeAws_restXmlListObjectVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8539,15 +8601,16 @@ const deserializeAws_restXmlListPartsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8576,15 +8639,16 @@ const deserializeAws_restXmlPutBucketAccelerateConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8613,15 +8677,16 @@ const deserializeAws_restXmlPutBucketAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8650,15 +8715,16 @@ const deserializeAws_restXmlPutBucketAnalyticsConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8687,15 +8753,16 @@ const deserializeAws_restXmlPutBucketCorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8724,15 +8791,16 @@ const deserializeAws_restXmlPutBucketEncryptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8761,15 +8829,16 @@ const deserializeAws_restXmlPutBucketIntelligentTieringConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8798,15 +8867,16 @@ const deserializeAws_restXmlPutBucketInventoryConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8835,15 +8905,16 @@ const deserializeAws_restXmlPutBucketLifecycleConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8872,15 +8943,16 @@ const deserializeAws_restXmlPutBucketLoggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8909,15 +8981,16 @@ const deserializeAws_restXmlPutBucketMetricsConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8946,15 +9019,16 @@ const deserializeAws_restXmlPutBucketNotificationConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8983,15 +9057,16 @@ const deserializeAws_restXmlPutBucketOwnershipControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9020,15 +9095,16 @@ const deserializeAws_restXmlPutBucketPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9057,15 +9133,16 @@ const deserializeAws_restXmlPutBucketReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9094,15 +9171,16 @@ const deserializeAws_restXmlPutBucketRequestPaymentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9131,15 +9209,16 @@ const deserializeAws_restXmlPutBucketTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9168,15 +9247,16 @@ const deserializeAws_restXmlPutBucketVersioningCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9205,15 +9285,16 @@ const deserializeAws_restXmlPutBucketWebsiteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9298,15 +9379,16 @@ const deserializeAws_restXmlPutObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9339,18 +9421,19 @@ const deserializeAws_restXmlPutObjectAclCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "NoSuchKey": case "com.amazonaws.s3#NoSuchKey": throw await deserializeAws_restXmlNoSuchKeyResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9383,15 +9466,16 @@ const deserializeAws_restXmlPutObjectLegalHoldCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9424,15 +9508,16 @@ const deserializeAws_restXmlPutObjectLockConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9465,15 +9550,16 @@ const deserializeAws_restXmlPutObjectRetentionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9506,15 +9592,16 @@ const deserializeAws_restXmlPutObjectTaggingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9543,15 +9630,16 @@ const deserializeAws_restXmlPutPublicAccessBlockCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9588,18 +9676,19 @@ const deserializeAws_restXmlRestoreObjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ObjectAlreadyInActiveTierError": case "com.amazonaws.s3#ObjectAlreadyInActiveTierError": throw await deserializeAws_restXmlObjectAlreadyInActiveTierErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9644,15 +9733,16 @@ const deserializeAws_restXmlSelectObjectContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9725,15 +9815,16 @@ const deserializeAws_restXmlUploadPartCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9792,15 +9883,16 @@ const deserializeAws_restXmlUploadPartCopyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9829,15 +9921,16 @@ const deserializeAws_restXmlWriteGetObjectResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14767,12 +14860,11 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => return {}; }); -const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Code !== undefined) { return data.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-s3outposts/src/protocols/Aws_restJson1.ts b/clients/client-s3outposts/src/protocols/Aws_restJson1.ts index 757ecdfa74acf..055717d85703d 100644 --- a/clients/client-s3outposts/src/protocols/Aws_restJson1.ts +++ b/clients/client-s3outposts/src/protocols/Aws_restJson1.ts @@ -167,8 +167,7 @@ const deserializeAws_restJson1CreateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.s3outposts#AccessDeniedException": @@ -187,10 +186,12 @@ const deserializeAws_restJson1CreateEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -219,8 +220,7 @@ const deserializeAws_restJson1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.s3outposts#AccessDeniedException": @@ -236,10 +236,12 @@ const deserializeAws_restJson1DeleteEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -276,8 +278,7 @@ const deserializeAws_restJson1ListEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.s3outposts#AccessDeniedException": @@ -293,10 +294,12 @@ const deserializeAws_restJson1ListEndpointsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -333,8 +336,7 @@ const deserializeAws_restJson1ListSharedEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.s3outposts#AccessDeniedException": @@ -350,10 +352,12 @@ const deserializeAws_restJson1ListSharedEndpointsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -528,7 +532,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -554,6 +558,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sagemaker-a2i-runtime/src/protocols/Aws_restJson1.ts b/clients/client-sagemaker-a2i-runtime/src/protocols/Aws_restJson1.ts index ff1b83cf9df85..7386d2a303251 100644 --- a/clients/client-sagemaker-a2i-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-sagemaker-a2i-runtime/src/protocols/Aws_restJson1.ts @@ -206,8 +206,7 @@ const deserializeAws_restJson1DeleteHumanLoopCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.sagemakera2iruntime#InternalServerException": @@ -223,10 +222,12 @@ const deserializeAws_restJson1DeleteHumanLoopCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -287,8 +288,7 @@ const deserializeAws_restJson1DescribeHumanLoopCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.sagemakera2iruntime#InternalServerException": @@ -304,10 +304,12 @@ const deserializeAws_restJson1DescribeHumanLoopCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -344,8 +346,7 @@ const deserializeAws_restJson1ListHumanLoopsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.sagemakera2iruntime#InternalServerException": @@ -361,10 +362,12 @@ const deserializeAws_restJson1ListHumanLoopsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -397,8 +400,7 @@ const deserializeAws_restJson1StartHumanLoopCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemakera2iruntime#ConflictException": @@ -417,10 +419,12 @@ const deserializeAws_restJson1StartHumanLoopCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -449,8 +453,7 @@ const deserializeAws_restJson1StopHumanLoopCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.sagemakera2iruntime#InternalServerException": @@ -466,10 +469,12 @@ const deserializeAws_restJson1StopHumanLoopCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -671,7 +676,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -697,6 +702,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sagemaker-edge/src/protocols/Aws_restJson1.ts b/clients/client-sagemaker-edge/src/protocols/Aws_restJson1.ts index 02f8109c2a6f1..aeb4dd2d0bb57 100644 --- a/clients/client-sagemaker-edge/src/protocols/Aws_restJson1.ts +++ b/clients/client-sagemaker-edge/src/protocols/Aws_restJson1.ts @@ -109,18 +109,19 @@ const deserializeAws_restJson1GetDeviceRegistrationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.sagemakeredge#InternalServiceException": throw await deserializeAws_restJson1InternalServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -149,18 +150,19 @@ const deserializeAws_restJson1SendHeartbeatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceException": case "com.amazonaws.sagemakeredge#InternalServiceException": throw await deserializeAws_restJson1InternalServiceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -264,7 +266,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -290,6 +292,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sagemaker-featurestore-runtime/src/protocols/Aws_restJson1.ts b/clients/client-sagemaker-featurestore-runtime/src/protocols/Aws_restJson1.ts index d6d31268e3336..8f9079dc7dd6a 100644 --- a/clients/client-sagemaker-featurestore-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-sagemaker-featurestore-runtime/src/protocols/Aws_restJson1.ts @@ -202,8 +202,7 @@ const deserializeAws_restJson1BatchGetRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessForbidden": case "com.amazonaws.sagemakerfeaturestoreruntime#AccessForbidden": @@ -219,10 +218,12 @@ const deserializeAws_restJson1BatchGetRecordCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -251,8 +252,7 @@ const deserializeAws_restJson1DeleteRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessForbidden": case "com.amazonaws.sagemakerfeaturestoreruntime#AccessForbidden": @@ -268,10 +268,12 @@ const deserializeAws_restJson1DeleteRecordCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -304,8 +306,7 @@ const deserializeAws_restJson1GetRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessForbidden": case "com.amazonaws.sagemakerfeaturestoreruntime#AccessForbidden": @@ -324,10 +325,12 @@ const deserializeAws_restJson1GetRecordCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -356,8 +359,7 @@ const deserializeAws_restJson1PutRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessForbidden": case "com.amazonaws.sagemakerfeaturestoreruntime#AccessForbidden": @@ -373,10 +375,12 @@ const deserializeAws_restJson1PutRecordCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -697,7 +701,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -723,6 +727,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sagemaker-runtime/src/protocols/Aws_restJson1.ts b/clients/client-sagemaker-runtime/src/protocols/Aws_restJson1.ts index 289341531827e..76da9d4a805a0 100644 --- a/clients/client-sagemaker-runtime/src/protocols/Aws_restJson1.ts +++ b/clients/client-sagemaker-runtime/src/protocols/Aws_restJson1.ts @@ -152,8 +152,7 @@ const deserializeAws_restJson1InvokeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalDependencyException": case "com.amazonaws.sagemakerruntime#InternalDependencyException": @@ -175,10 +174,12 @@ const deserializeAws_restJson1InvokeEndpointCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -215,8 +216,7 @@ const deserializeAws_restJson1InvokeEndpointAsyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalFailure": case "com.amazonaws.sagemakerruntime#InternalFailure": @@ -229,10 +229,12 @@ const deserializeAws_restJson1InvokeEndpointAsyncCommandError = async ( throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -380,7 +382,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -406,6 +408,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sagemaker/src/protocols/Aws_json1_1.ts b/clients/client-sagemaker/src/protocols/Aws_json1_1.ts index f3ba914544267..5b6391aa80954 100644 --- a/clients/client-sagemaker/src/protocols/Aws_json1_1.ts +++ b/clients/client-sagemaker/src/protocols/Aws_json1_1.ts @@ -4810,8 +4810,7 @@ const deserializeAws_json1_1AddAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -4821,10 +4820,12 @@ const deserializeAws_json1_1AddAssociationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4856,15 +4857,16 @@ const deserializeAws_json1_1AddTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4896,8 +4898,7 @@ const deserializeAws_json1_1AssociateTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -4907,10 +4908,12 @@ const deserializeAws_json1_1AssociateTrialComponentCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4942,15 +4945,16 @@ const deserializeAws_json1_1BatchDescribeModelPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4982,18 +4986,19 @@ const deserializeAws_json1_1CreateActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5025,15 +5030,16 @@ const deserializeAws_json1_1CreateAlgorithmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5065,8 +5071,7 @@ const deserializeAws_json1_1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5076,10 +5081,12 @@ const deserializeAws_json1_1CreateAppCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5111,18 +5118,19 @@ const deserializeAws_json1_1CreateAppImageConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5154,18 +5162,19 @@ const deserializeAws_json1_1CreateArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5197,8 +5206,7 @@ const deserializeAws_json1_1CreateAutoMLJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5208,10 +5216,12 @@ const deserializeAws_json1_1CreateAutoMLJobCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5243,15 +5253,16 @@ const deserializeAws_json1_1CreateCodeRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5283,8 +5294,7 @@ const deserializeAws_json1_1CreateCompilationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5294,10 +5304,12 @@ const deserializeAws_json1_1CreateCompilationJobCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5329,18 +5341,19 @@ const deserializeAws_json1_1CreateContextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5372,8 +5385,7 @@ const deserializeAws_json1_1CreateDataQualityJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5383,10 +5395,12 @@ const deserializeAws_json1_1CreateDataQualityJobDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5415,8 +5429,7 @@ const deserializeAws_json1_1CreateDeviceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5426,10 +5439,12 @@ const deserializeAws_json1_1CreateDeviceFleetCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5461,8 +5476,7 @@ const deserializeAws_json1_1CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5472,10 +5486,12 @@ const deserializeAws_json1_1CreateDomainCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5504,18 +5520,19 @@ const deserializeAws_json1_1CreateEdgePackagingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5547,18 +5564,19 @@ const deserializeAws_json1_1CreateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5590,18 +5608,19 @@ const deserializeAws_json1_1CreateEndpointConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5633,18 +5652,19 @@ const deserializeAws_json1_1CreateExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5676,8 +5696,7 @@ const deserializeAws_json1_1CreateFeatureGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5687,10 +5706,12 @@ const deserializeAws_json1_1CreateFeatureGroupCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5722,8 +5743,7 @@ const deserializeAws_json1_1CreateFlowDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5733,10 +5753,12 @@ const deserializeAws_json1_1CreateFlowDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5768,8 +5790,7 @@ const deserializeAws_json1_1CreateHumanTaskUiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5779,10 +5800,12 @@ const deserializeAws_json1_1CreateHumanTaskUiCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5814,8 +5837,7 @@ const deserializeAws_json1_1CreateHyperParameterTuningJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5825,10 +5847,12 @@ const deserializeAws_json1_1CreateHyperParameterTuningJobCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5860,8 +5884,7 @@ const deserializeAws_json1_1CreateImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5871,10 +5894,12 @@ const deserializeAws_json1_1CreateImageCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5906,8 +5931,7 @@ const deserializeAws_json1_1CreateImageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5920,10 +5944,12 @@ const deserializeAws_json1_1CreateImageVersionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5955,8 +5981,7 @@ const deserializeAws_json1_1CreateInferenceRecommendationsJobCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -5966,10 +5991,12 @@ const deserializeAws_json1_1CreateInferenceRecommendationsJobCommandError = asyn throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6001,8 +6028,7 @@ const deserializeAws_json1_1CreateLabelingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6012,10 +6038,12 @@ const deserializeAws_json1_1CreateLabelingJobCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6047,18 +6075,19 @@ const deserializeAws_json1_1CreateModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6090,8 +6119,7 @@ const deserializeAws_json1_1CreateModelBiasJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6101,10 +6129,12 @@ const deserializeAws_json1_1CreateModelBiasJobDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6136,8 +6166,7 @@ const deserializeAws_json1_1CreateModelExplainabilityJobDefinitionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6147,10 +6176,12 @@ const deserializeAws_json1_1CreateModelExplainabilityJobDefinitionCommandError = throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6182,8 +6213,7 @@ const deserializeAws_json1_1CreateModelPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -6193,10 +6223,12 @@ const deserializeAws_json1_1CreateModelPackageCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6228,18 +6260,19 @@ const deserializeAws_json1_1CreateModelPackageGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6271,8 +6304,7 @@ const deserializeAws_json1_1CreateModelQualityJobDefinitionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6282,10 +6314,12 @@ const deserializeAws_json1_1CreateModelQualityJobDefinitionCommandError = async throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6317,8 +6351,7 @@ const deserializeAws_json1_1CreateMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6328,10 +6361,12 @@ const deserializeAws_json1_1CreateMonitoringScheduleCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6363,18 +6398,19 @@ const deserializeAws_json1_1CreateNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6406,18 +6442,19 @@ const deserializeAws_json1_1CreateNotebookInstanceLifecycleConfigCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6449,8 +6486,7 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -6460,10 +6496,12 @@ const deserializeAws_json1_1CreatePipelineCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6495,18 +6533,19 @@ const deserializeAws_json1_1CreatePresignedDomainUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6538,15 +6577,16 @@ const deserializeAws_json1_1CreatePresignedNotebookInstanceUrlCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6578,8 +6618,7 @@ const deserializeAws_json1_1CreateProcessingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6592,10 +6631,12 @@ const deserializeAws_json1_1CreateProcessingJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6627,18 +6668,19 @@ const deserializeAws_json1_1CreateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6670,18 +6712,19 @@ const deserializeAws_json1_1CreateStudioLifecycleConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6713,8 +6756,7 @@ const deserializeAws_json1_1CreateTrainingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6727,10 +6769,12 @@ const deserializeAws_json1_1CreateTrainingJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6762,8 +6806,7 @@ const deserializeAws_json1_1CreateTransformJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6776,10 +6819,12 @@ const deserializeAws_json1_1CreateTransformJobCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6811,8 +6856,7 @@ const deserializeAws_json1_1CreateTrialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -6822,10 +6866,12 @@ const deserializeAws_json1_1CreateTrialCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6857,18 +6903,19 @@ const deserializeAws_json1_1CreateTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6900,8 +6947,7 @@ const deserializeAws_json1_1CreateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6911,10 +6957,12 @@ const deserializeAws_json1_1CreateUserProfileCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6946,15 +6994,16 @@ const deserializeAws_json1_1CreateWorkforceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6986,8 +7035,7 @@ const deserializeAws_json1_1CreateWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -6997,10 +7045,12 @@ const deserializeAws_json1_1CreateWorkteamCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7032,18 +7082,19 @@ const deserializeAws_json1_1DeleteActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7072,15 +7123,16 @@ const deserializeAws_json1_1DeleteAlgorithmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7109,8 +7161,7 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -7120,10 +7171,12 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7152,18 +7205,19 @@ const deserializeAws_json1_1DeleteAppImageConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7195,18 +7249,19 @@ const deserializeAws_json1_1DeleteArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7238,18 +7293,19 @@ const deserializeAws_json1_1DeleteAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7278,15 +7334,16 @@ const deserializeAws_json1_1DeleteCodeRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7318,18 +7375,19 @@ const deserializeAws_json1_1DeleteContextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7358,18 +7416,19 @@ const deserializeAws_json1_1DeleteDataQualityJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7398,18 +7457,19 @@ const deserializeAws_json1_1DeleteDeviceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7438,8 +7498,7 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -7449,10 +7508,12 @@ const deserializeAws_json1_1DeleteDomainCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7481,15 +7542,16 @@ const deserializeAws_json1_1DeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7518,15 +7580,16 @@ const deserializeAws_json1_1DeleteEndpointConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7558,18 +7621,19 @@ const deserializeAws_json1_1DeleteExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7598,18 +7662,19 @@ const deserializeAws_json1_1DeleteFeatureGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7641,8 +7706,7 @@ const deserializeAws_json1_1DeleteFlowDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -7652,10 +7716,12 @@ const deserializeAws_json1_1DeleteFlowDefinitionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7687,18 +7753,19 @@ const deserializeAws_json1_1DeleteHumanTaskUiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7730,8 +7797,7 @@ const deserializeAws_json1_1DeleteImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -7741,10 +7807,12 @@ const deserializeAws_json1_1DeleteImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7776,8 +7844,7 @@ const deserializeAws_json1_1DeleteImageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -7787,10 +7854,12 @@ const deserializeAws_json1_1DeleteImageVersionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7819,15 +7888,16 @@ const deserializeAws_json1_1DeleteModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7856,18 +7926,19 @@ const deserializeAws_json1_1DeleteModelBiasJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7896,18 +7967,19 @@ const deserializeAws_json1_1DeleteModelExplainabilityJobDefinitionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7936,18 +8008,19 @@ const deserializeAws_json1_1DeleteModelPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": throw await deserializeAws_json1_1ConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7976,18 +8049,19 @@ const deserializeAws_json1_1DeleteModelPackageGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": throw await deserializeAws_json1_1ConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8016,15 +8090,16 @@ const deserializeAws_json1_1DeleteModelPackageGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8053,18 +8128,19 @@ const deserializeAws_json1_1DeleteModelQualityJobDefinitionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8093,18 +8169,19 @@ const deserializeAws_json1_1DeleteMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8133,15 +8210,16 @@ const deserializeAws_json1_1DeleteNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8170,15 +8248,16 @@ const deserializeAws_json1_1DeleteNotebookInstanceLifecycleConfigCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8210,18 +8289,19 @@ const deserializeAws_json1_1DeletePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8250,18 +8330,19 @@ const deserializeAws_json1_1DeleteProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": throw await deserializeAws_json1_1ConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8290,8 +8371,7 @@ const deserializeAws_json1_1DeleteStudioLifecycleConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -8301,10 +8381,12 @@ const deserializeAws_json1_1DeleteStudioLifecycleConfigCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8336,15 +8418,16 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8376,18 +8459,19 @@ const deserializeAws_json1_1DeleteTrialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8419,18 +8503,19 @@ const deserializeAws_json1_1DeleteTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8459,8 +8544,7 @@ const deserializeAws_json1_1DeleteUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -8470,10 +8554,12 @@ const deserializeAws_json1_1DeleteUserProfileCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8505,15 +8591,16 @@ const deserializeAws_json1_1DeleteWorkforceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8545,18 +8632,19 @@ const deserializeAws_json1_1DeleteWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8585,15 +8673,16 @@ const deserializeAws_json1_1DeregisterDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8625,18 +8714,19 @@ const deserializeAws_json1_1DescribeActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8668,15 +8758,16 @@ const deserializeAws_json1_1DescribeAlgorithmCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8708,18 +8799,19 @@ const deserializeAws_json1_1DescribeAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8751,18 +8843,19 @@ const deserializeAws_json1_1DescribeAppImageConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8794,18 +8887,19 @@ const deserializeAws_json1_1DescribeArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8837,18 +8931,19 @@ const deserializeAws_json1_1DescribeAutoMLJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8880,15 +8975,16 @@ const deserializeAws_json1_1DescribeCodeRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8920,18 +9016,19 @@ const deserializeAws_json1_1DescribeCompilationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8963,18 +9060,19 @@ const deserializeAws_json1_1DescribeContextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9006,18 +9104,19 @@ const deserializeAws_json1_1DescribeDataQualityJobDefinitionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9049,18 +9148,19 @@ const deserializeAws_json1_1DescribeDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9092,18 +9192,19 @@ const deserializeAws_json1_1DescribeDeviceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9135,18 +9236,19 @@ const deserializeAws_json1_1DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9178,18 +9280,19 @@ const deserializeAws_json1_1DescribeEdgePackagingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9221,15 +9324,16 @@ const deserializeAws_json1_1DescribeEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9261,15 +9365,16 @@ const deserializeAws_json1_1DescribeEndpointConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9301,18 +9406,19 @@ const deserializeAws_json1_1DescribeExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9344,18 +9450,19 @@ const deserializeAws_json1_1DescribeFeatureGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9387,18 +9494,19 @@ const deserializeAws_json1_1DescribeFlowDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9430,18 +9538,19 @@ const deserializeAws_json1_1DescribeHumanTaskUiCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9473,18 +9582,19 @@ const deserializeAws_json1_1DescribeHyperParameterTuningJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9516,18 +9626,19 @@ const deserializeAws_json1_1DescribeImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9559,18 +9670,19 @@ const deserializeAws_json1_1DescribeImageVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9602,18 +9714,19 @@ const deserializeAws_json1_1DescribeInferenceRecommendationsJobCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9645,18 +9758,19 @@ const deserializeAws_json1_1DescribeLabelingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9688,18 +9802,19 @@ const deserializeAws_json1_1DescribeLineageGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9731,15 +9846,16 @@ const deserializeAws_json1_1DescribeModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9771,18 +9887,19 @@ const deserializeAws_json1_1DescribeModelBiasJobDefinitionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9814,18 +9931,19 @@ const deserializeAws_json1_1DescribeModelExplainabilityJobDefinitionCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9857,15 +9975,16 @@ const deserializeAws_json1_1DescribeModelPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9897,15 +10016,16 @@ const deserializeAws_json1_1DescribeModelPackageGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9937,18 +10057,19 @@ const deserializeAws_json1_1DescribeModelQualityJobDefinitionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9980,18 +10101,19 @@ const deserializeAws_json1_1DescribeMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10023,15 +10145,16 @@ const deserializeAws_json1_1DescribeNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10063,15 +10186,16 @@ const deserializeAws_json1_1DescribeNotebookInstanceLifecycleConfigCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10103,18 +10227,19 @@ const deserializeAws_json1_1DescribePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10146,18 +10271,19 @@ const deserializeAws_json1_1DescribePipelineDefinitionForExecutionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10189,18 +10315,19 @@ const deserializeAws_json1_1DescribePipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10232,18 +10359,19 @@ const deserializeAws_json1_1DescribeProcessingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10275,15 +10403,16 @@ const deserializeAws_json1_1DescribeProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10315,18 +10444,19 @@ const deserializeAws_json1_1DescribeStudioLifecycleConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10358,15 +10488,16 @@ const deserializeAws_json1_1DescribeSubscribedWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10398,18 +10529,19 @@ const deserializeAws_json1_1DescribeTrainingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10441,18 +10573,19 @@ const deserializeAws_json1_1DescribeTransformJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10484,18 +10617,19 @@ const deserializeAws_json1_1DescribeTrialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10527,18 +10661,19 @@ const deserializeAws_json1_1DescribeTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10570,18 +10705,19 @@ const deserializeAws_json1_1DescribeUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10613,15 +10749,16 @@ const deserializeAws_json1_1DescribeWorkforceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10653,15 +10790,16 @@ const deserializeAws_json1_1DescribeWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10693,15 +10831,16 @@ const deserializeAws_json1_1DisableSagemakerServicecatalogPortfolioCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10733,18 +10872,19 @@ const deserializeAws_json1_1DisassociateTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10776,15 +10916,16 @@ const deserializeAws_json1_1EnableSagemakerServicecatalogPortfolioCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10816,15 +10957,16 @@ const deserializeAws_json1_1GetDeviceFleetReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10856,18 +10998,19 @@ const deserializeAws_json1_1GetLineageGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10899,15 +11042,16 @@ const deserializeAws_json1_1GetModelPackageGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10939,15 +11083,16 @@ const deserializeAws_json1_1GetSagemakerServicecatalogPortfolioStatusCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -10979,15 +11124,16 @@ const deserializeAws_json1_1GetSearchSuggestionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11019,18 +11165,19 @@ const deserializeAws_json1_1ListActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11062,15 +11209,16 @@ const deserializeAws_json1_1ListAlgorithmsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11102,15 +11250,16 @@ const deserializeAws_json1_1ListAppImageConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11142,15 +11291,16 @@ const deserializeAws_json1_1ListAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11182,18 +11332,19 @@ const deserializeAws_json1_1ListArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11225,18 +11376,19 @@ const deserializeAws_json1_1ListAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11268,15 +11420,16 @@ const deserializeAws_json1_1ListAutoMLJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11308,18 +11461,19 @@ const deserializeAws_json1_1ListCandidatesForAutoMLJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11351,15 +11505,16 @@ const deserializeAws_json1_1ListCodeRepositoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11391,15 +11546,16 @@ const deserializeAws_json1_1ListCompilationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11431,18 +11587,19 @@ const deserializeAws_json1_1ListContextsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11474,15 +11631,16 @@ const deserializeAws_json1_1ListDataQualityJobDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11514,15 +11672,16 @@ const deserializeAws_json1_1ListDeviceFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11554,15 +11713,16 @@ const deserializeAws_json1_1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11594,15 +11754,16 @@ const deserializeAws_json1_1ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11634,15 +11795,16 @@ const deserializeAws_json1_1ListEdgePackagingJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11674,15 +11836,16 @@ const deserializeAws_json1_1ListEndpointConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11714,15 +11877,16 @@ const deserializeAws_json1_1ListEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11754,15 +11918,16 @@ const deserializeAws_json1_1ListExperimentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11794,15 +11959,16 @@ const deserializeAws_json1_1ListFeatureGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11834,15 +12000,16 @@ const deserializeAws_json1_1ListFlowDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11874,15 +12041,16 @@ const deserializeAws_json1_1ListHumanTaskUisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11914,15 +12082,16 @@ const deserializeAws_json1_1ListHyperParameterTuningJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11954,15 +12123,16 @@ const deserializeAws_json1_1ListImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -11994,18 +12164,19 @@ const deserializeAws_json1_1ListImageVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12037,15 +12208,16 @@ const deserializeAws_json1_1ListInferenceRecommendationsJobsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12077,15 +12249,16 @@ const deserializeAws_json1_1ListLabelingJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12117,18 +12290,19 @@ const deserializeAws_json1_1ListLabelingJobsForWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12160,15 +12334,16 @@ const deserializeAws_json1_1ListLineageGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12200,15 +12375,16 @@ const deserializeAws_json1_1ListModelBiasJobDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12240,15 +12416,16 @@ const deserializeAws_json1_1ListModelExplainabilityJobDefinitionsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12280,15 +12457,16 @@ const deserializeAws_json1_1ListModelMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12320,15 +12498,16 @@ const deserializeAws_json1_1ListModelPackageGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12360,15 +12539,16 @@ const deserializeAws_json1_1ListModelPackagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12400,15 +12580,16 @@ const deserializeAws_json1_1ListModelQualityJobDefinitionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12440,15 +12621,16 @@ const deserializeAws_json1_1ListModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12480,15 +12662,16 @@ const deserializeAws_json1_1ListMonitoringExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12520,15 +12703,16 @@ const deserializeAws_json1_1ListMonitoringSchedulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12560,15 +12744,16 @@ const deserializeAws_json1_1ListNotebookInstanceLifecycleConfigsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12600,15 +12785,16 @@ const deserializeAws_json1_1ListNotebookInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12640,18 +12826,19 @@ const deserializeAws_json1_1ListPipelineExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12683,18 +12870,19 @@ const deserializeAws_json1_1ListPipelineExecutionStepsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12726,18 +12914,19 @@ const deserializeAws_json1_1ListPipelineParametersForExecutionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12769,15 +12958,16 @@ const deserializeAws_json1_1ListPipelinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12809,15 +12999,16 @@ const deserializeAws_json1_1ListProcessingJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12849,15 +13040,16 @@ const deserializeAws_json1_1ListProjectsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12889,18 +13081,19 @@ const deserializeAws_json1_1ListStudioLifecycleConfigsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12932,15 +13125,16 @@ const deserializeAws_json1_1ListSubscribedWorkteamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -12972,15 +13166,16 @@ const deserializeAws_json1_1ListTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13012,15 +13207,16 @@ const deserializeAws_json1_1ListTrainingJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13052,18 +13248,19 @@ const deserializeAws_json1_1ListTrainingJobsForHyperParameterTuningJobCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13095,15 +13292,16 @@ const deserializeAws_json1_1ListTransformJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13135,18 +13333,19 @@ const deserializeAws_json1_1ListTrialComponentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13178,18 +13377,19 @@ const deserializeAws_json1_1ListTrialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13221,15 +13421,16 @@ const deserializeAws_json1_1ListUserProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13261,15 +13462,16 @@ const deserializeAws_json1_1ListWorkforcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13301,15 +13503,16 @@ const deserializeAws_json1_1ListWorkteamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13341,15 +13544,16 @@ const deserializeAws_json1_1PutModelPackageGroupPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13381,18 +13585,19 @@ const deserializeAws_json1_1QueryLineageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13421,18 +13626,19 @@ const deserializeAws_json1_1RegisterDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13464,18 +13670,19 @@ const deserializeAws_json1_1RenderUiTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13507,8 +13714,7 @@ const deserializeAws_json1_1RetryPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -13521,10 +13727,12 @@ const deserializeAws_json1_1RetryPipelineExecutionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13556,15 +13764,16 @@ const deserializeAws_json1_1SearchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13596,8 +13805,7 @@ const deserializeAws_json1_1SendPipelineExecutionStepFailureCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -13607,10 +13815,12 @@ const deserializeAws_json1_1SendPipelineExecutionStepFailureCommandError = async throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13642,8 +13852,7 @@ const deserializeAws_json1_1SendPipelineExecutionStepSuccessCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -13653,10 +13862,12 @@ const deserializeAws_json1_1SendPipelineExecutionStepSuccessCommandError = async throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13685,18 +13896,19 @@ const deserializeAws_json1_1StartMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13725,18 +13937,19 @@ const deserializeAws_json1_1StartNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13768,8 +13981,7 @@ const deserializeAws_json1_1StartPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -13779,10 +13991,12 @@ const deserializeAws_json1_1StartPipelineExecutionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13811,18 +14025,19 @@ const deserializeAws_json1_1StopAutoMLJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13851,18 +14066,19 @@ const deserializeAws_json1_1StopCompilationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13891,15 +14107,16 @@ const deserializeAws_json1_1StopEdgePackagingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13928,18 +14145,19 @@ const deserializeAws_json1_1StopHyperParameterTuningJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -13968,18 +14186,19 @@ const deserializeAws_json1_1StopInferenceRecommendationsJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14008,18 +14227,19 @@ const deserializeAws_json1_1StopLabelingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14048,18 +14268,19 @@ const deserializeAws_json1_1StopMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14088,15 +14309,16 @@ const deserializeAws_json1_1StopNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14128,18 +14350,19 @@ const deserializeAws_json1_1StopPipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14168,18 +14391,19 @@ const deserializeAws_json1_1StopProcessingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14208,18 +14432,19 @@ const deserializeAws_json1_1StopTrainingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14248,18 +14473,19 @@ const deserializeAws_json1_1StopTransformJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14291,8 +14517,7 @@ const deserializeAws_json1_1UpdateActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -14302,10 +14527,12 @@ const deserializeAws_json1_1UpdateActionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14337,18 +14564,19 @@ const deserializeAws_json1_1UpdateAppImageConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14380,8 +14608,7 @@ const deserializeAws_json1_1UpdateArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -14391,10 +14618,12 @@ const deserializeAws_json1_1UpdateArtifactCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14426,15 +14655,16 @@ const deserializeAws_json1_1UpdateCodeRepositoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14466,8 +14696,7 @@ const deserializeAws_json1_1UpdateContextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -14477,10 +14706,12 @@ const deserializeAws_json1_1UpdateContextCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14509,18 +14740,19 @@ const deserializeAws_json1_1UpdateDeviceFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14549,15 +14781,16 @@ const deserializeAws_json1_1UpdateDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14589,8 +14822,7 @@ const deserializeAws_json1_1UpdateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -14603,10 +14835,12 @@ const deserializeAws_json1_1UpdateDomainCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14638,18 +14872,19 @@ const deserializeAws_json1_1UpdateEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14681,18 +14916,19 @@ const deserializeAws_json1_1UpdateEndpointWeightsAndCapacitiesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14724,8 +14960,7 @@ const deserializeAws_json1_1UpdateExperimentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -14735,10 +14970,12 @@ const deserializeAws_json1_1UpdateExperimentCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14770,8 +15007,7 @@ const deserializeAws_json1_1UpdateImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -14781,10 +15017,12 @@ const deserializeAws_json1_1UpdateImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14816,15 +15054,16 @@ const deserializeAws_json1_1UpdateModelPackageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14856,8 +15095,7 @@ const deserializeAws_json1_1UpdateMonitoringScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": @@ -14867,10 +15105,12 @@ const deserializeAws_json1_1UpdateMonitoringScheduleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14902,18 +15142,19 @@ const deserializeAws_json1_1UpdateNotebookInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14945,18 +15186,19 @@ const deserializeAws_json1_1UpdateNotebookInstanceLifecycleConfigCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -14988,18 +15230,19 @@ const deserializeAws_json1_1UpdatePipelineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15031,18 +15274,19 @@ const deserializeAws_json1_1UpdatePipelineExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15074,15 +15318,16 @@ const deserializeAws_json1_1UpdateProjectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15114,18 +15359,19 @@ const deserializeAws_json1_1UpdateTrainingJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFound": case "com.amazonaws.sagemaker#ResourceNotFound": throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15157,8 +15403,7 @@ const deserializeAws_json1_1UpdateTrialCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -15168,10 +15413,12 @@ const deserializeAws_json1_1UpdateTrialCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15203,8 +15450,7 @@ const deserializeAws_json1_1UpdateTrialComponentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": @@ -15214,10 +15460,12 @@ const deserializeAws_json1_1UpdateTrialComponentCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15249,8 +15497,7 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUse": case "com.amazonaws.sagemaker#ResourceInUse": @@ -15263,10 +15510,12 @@ const deserializeAws_json1_1UpdateUserProfileCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15298,18 +15547,19 @@ const deserializeAws_json1_1UpdateWorkforceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.sagemaker#ConflictException": throw await deserializeAws_json1_1ConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -15341,18 +15591,19 @@ const deserializeAws_json1_1UpdateWorkteamCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceLimitExceeded": case "com.amazonaws.sagemaker#ResourceLimitExceeded": throw await deserializeAws_json1_1ResourceLimitExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -34988,7 +35239,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -35014,6 +35265,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-savingsplans/src/protocols/Aws_restJson1.ts b/clients/client-savingsplans/src/protocols/Aws_restJson1.ts index 202decb735093..4e0c0e7ce5f40 100644 --- a/clients/client-savingsplans/src/protocols/Aws_restJson1.ts +++ b/clients/client-savingsplans/src/protocols/Aws_restJson1.ts @@ -412,8 +412,7 @@ const deserializeAws_restJson1CreateSavingsPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -429,10 +428,12 @@ const deserializeAws_restJson1CreateSavingsPlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -461,8 +462,7 @@ const deserializeAws_restJson1DeleteQueuedSavingsPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -478,10 +478,12 @@ const deserializeAws_restJson1DeleteQueuedSavingsPlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -522,8 +524,7 @@ const deserializeAws_restJson1DescribeSavingsPlanRatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.savingsplans#ResourceNotFoundException": @@ -533,10 +534,12 @@ const deserializeAws_restJson1DescribeSavingsPlanRatesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -573,8 +576,7 @@ const deserializeAws_restJson1DescribeSavingsPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -584,10 +586,12 @@ const deserializeAws_restJson1DescribeSavingsPlansCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -624,8 +628,7 @@ const deserializeAws_restJson1DescribeSavingsPlansOfferingRatesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -635,10 +638,12 @@ const deserializeAws_restJson1DescribeSavingsPlansOfferingRatesCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -675,8 +680,7 @@ const deserializeAws_restJson1DescribeSavingsPlansOfferingsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -686,10 +690,12 @@ const deserializeAws_restJson1DescribeSavingsPlansOfferingsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -722,8 +728,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -736,10 +741,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -768,8 +775,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -785,10 +791,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -817,8 +825,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.savingsplans#InternalServerException": @@ -831,10 +838,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1527,7 +1536,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1553,6 +1562,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-schemas/src/protocols/Aws_restJson1.ts b/clients/client-schemas/src/protocols/Aws_restJson1.ts index 1b16642b493b8..0b7d9c56b299a 100644 --- a/clients/client-schemas/src/protocols/Aws_restJson1.ts +++ b/clients/client-schemas/src/protocols/Aws_restJson1.ts @@ -1231,8 +1231,7 @@ const deserializeAws_restJson1CreateDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1254,10 +1253,12 @@ const deserializeAws_restJson1CreateDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1302,8 +1303,7 @@ const deserializeAws_restJson1CreateRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1325,10 +1325,12 @@ const deserializeAws_restJson1CreateRegistryCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1389,8 +1391,7 @@ const deserializeAws_restJson1CreateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1406,10 +1407,12 @@ const deserializeAws_restJson1CreateSchemaCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1438,8 +1441,7 @@ const deserializeAws_restJson1DeleteDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1461,10 +1463,12 @@ const deserializeAws_restJson1DeleteDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1493,8 +1497,7 @@ const deserializeAws_restJson1DeleteRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1516,10 +1519,12 @@ const deserializeAws_restJson1DeleteRegistryCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1548,8 +1553,7 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1571,10 +1575,12 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1603,8 +1609,7 @@ const deserializeAws_restJson1DeleteSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1626,10 +1631,12 @@ const deserializeAws_restJson1DeleteSchemaCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1658,8 +1665,7 @@ const deserializeAws_restJson1DeleteSchemaVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1681,10 +1687,12 @@ const deserializeAws_restJson1DeleteSchemaVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1729,8 +1737,7 @@ const deserializeAws_restJson1DescribeCodeBindingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1752,10 +1759,12 @@ const deserializeAws_restJson1DescribeCodeBindingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1812,8 +1821,7 @@ const deserializeAws_restJson1DescribeDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1835,10 +1843,12 @@ const deserializeAws_restJson1DescribeDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1883,8 +1893,7 @@ const deserializeAws_restJson1DescribeRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1906,10 +1915,12 @@ const deserializeAws_restJson1DescribeRegistryCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1974,8 +1985,7 @@ const deserializeAws_restJson1DescribeSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -1997,10 +2007,12 @@ const deserializeAws_restJson1DescribeSchemaCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2049,8 +2061,7 @@ const deserializeAws_restJson1ExportSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2075,10 +2086,12 @@ const deserializeAws_restJson1ExportSchemaCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2109,8 +2122,7 @@ const deserializeAws_restJson1GetCodeBindingSourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2132,10 +2144,12 @@ const deserializeAws_restJson1GetCodeBindingSourceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2168,8 +2182,7 @@ const deserializeAws_restJson1GetDiscoveredSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2188,10 +2201,12 @@ const deserializeAws_restJson1GetDiscoveredSchemaCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2228,8 +2243,7 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2251,10 +2265,12 @@ const deserializeAws_restJson1GetResourcePolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2291,8 +2307,7 @@ const deserializeAws_restJson1ListDiscoverersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2311,10 +2326,12 @@ const deserializeAws_restJson1ListDiscoverersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2351,8 +2368,7 @@ const deserializeAws_restJson1ListRegistriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2371,10 +2387,12 @@ const deserializeAws_restJson1ListRegistriesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2411,8 +2429,7 @@ const deserializeAws_restJson1ListSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2431,10 +2448,12 @@ const deserializeAws_restJson1ListSchemasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2471,8 +2490,7 @@ const deserializeAws_restJson1ListSchemaVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2494,10 +2512,12 @@ const deserializeAws_restJson1ListSchemaVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2530,8 +2550,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2547,10 +2566,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2595,8 +2616,7 @@ const deserializeAws_restJson1PutCodeBindingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2621,10 +2641,12 @@ const deserializeAws_restJson1PutCodeBindingCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2661,8 +2683,7 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2687,10 +2708,12 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2727,8 +2750,7 @@ const deserializeAws_restJson1SearchSchemasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2747,10 +2769,12 @@ const deserializeAws_restJson1SearchSchemasCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2787,8 +2811,7 @@ const deserializeAws_restJson1StartDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2810,10 +2833,12 @@ const deserializeAws_restJson1StartDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2850,8 +2875,7 @@ const deserializeAws_restJson1StopDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2873,10 +2897,12 @@ const deserializeAws_restJson1StopDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2905,8 +2931,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2922,10 +2947,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2954,8 +2981,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -2971,10 +2997,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3031,8 +3059,7 @@ const deserializeAws_restJson1UpdateDiscovererCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -3054,10 +3081,12 @@ const deserializeAws_restJson1UpdateDiscovererCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3102,8 +3131,7 @@ const deserializeAws_restJson1UpdateRegistryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -3125,10 +3153,12 @@ const deserializeAws_restJson1UpdateRegistryCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3189,8 +3219,7 @@ const deserializeAws_restJson1UpdateSchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.schemas#BadRequestException": @@ -3209,10 +3238,12 @@ const deserializeAws_restJson1UpdateSchemaCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3643,7 +3674,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3669,6 +3700,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-secrets-manager/src/protocols/Aws_json1_1.ts b/clients/client-secrets-manager/src/protocols/Aws_json1_1.ts index 6f6c712992630..764126276da88 100644 --- a/clients/client-secrets-manager/src/protocols/Aws_json1_1.ts +++ b/clients/client-secrets-manager/src/protocols/Aws_json1_1.ts @@ -438,8 +438,7 @@ const deserializeAws_json1_1CancelRotateSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -455,10 +454,12 @@ const deserializeAws_json1_1CancelRotateSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -490,8 +491,7 @@ const deserializeAws_json1_1CreateSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DecryptionFailure": case "com.amazonaws.secretsmanager#DecryptionFailure": @@ -525,10 +525,12 @@ const deserializeAws_json1_1CreateSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -560,8 +562,7 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -577,10 +578,12 @@ const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -612,8 +615,7 @@ const deserializeAws_json1_1DeleteSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -629,10 +631,12 @@ const deserializeAws_json1_1DeleteSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -664,8 +668,7 @@ const deserializeAws_json1_1DescribeSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -678,10 +681,12 @@ const deserializeAws_json1_1DescribeSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -713,8 +718,7 @@ const deserializeAws_json1_1GetRandomPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -727,10 +731,12 @@ const deserializeAws_json1_1GetRandomPasswordCommandError = async ( throw await deserializeAws_json1_1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -762,8 +768,7 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -779,10 +784,12 @@ const deserializeAws_json1_1GetResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -814,8 +821,7 @@ const deserializeAws_json1_1GetSecretValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DecryptionFailure": case "com.amazonaws.secretsmanager#DecryptionFailure": @@ -834,10 +840,12 @@ const deserializeAws_json1_1GetSecretValueCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -869,8 +877,7 @@ const deserializeAws_json1_1ListSecretsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -883,10 +890,12 @@ const deserializeAws_json1_1ListSecretsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -918,8 +927,7 @@ const deserializeAws_json1_1ListSecretVersionIdsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -935,10 +943,12 @@ const deserializeAws_json1_1ListSecretVersionIdsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -970,8 +980,7 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -993,10 +1002,12 @@ const deserializeAws_json1_1PutResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1028,8 +1039,7 @@ const deserializeAws_json1_1PutSecretValueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DecryptionFailure": case "com.amazonaws.secretsmanager#DecryptionFailure": @@ -1057,10 +1067,12 @@ const deserializeAws_json1_1PutSecretValueCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1092,8 +1104,7 @@ const deserializeAws_json1_1RemoveRegionsFromReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1109,10 +1120,12 @@ const deserializeAws_json1_1RemoveRegionsFromReplicationCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1144,8 +1157,7 @@ const deserializeAws_json1_1ReplicateSecretToRegionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1161,10 +1173,12 @@ const deserializeAws_json1_1ReplicateSecretToRegionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1196,8 +1210,7 @@ const deserializeAws_json1_1RestoreSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1213,10 +1226,12 @@ const deserializeAws_json1_1RestoreSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1248,8 +1263,7 @@ const deserializeAws_json1_1RotateSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1265,10 +1279,12 @@ const deserializeAws_json1_1RotateSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1300,8 +1316,7 @@ const deserializeAws_json1_1StopReplicationToReplicaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1317,10 +1332,12 @@ const deserializeAws_json1_1StopReplicationToReplicaCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1349,8 +1366,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1366,10 +1382,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1398,8 +1416,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1415,10 +1432,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1450,8 +1469,7 @@ const deserializeAws_json1_1UpdateSecretCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DecryptionFailure": case "com.amazonaws.secretsmanager#DecryptionFailure": @@ -1485,10 +1503,12 @@ const deserializeAws_json1_1UpdateSecretCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1520,8 +1540,7 @@ const deserializeAws_json1_1UpdateSecretVersionStageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1540,10 +1559,12 @@ const deserializeAws_json1_1UpdateSecretVersionStageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1575,8 +1596,7 @@ const deserializeAws_json1_1ValidateResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.secretsmanager#InternalServiceError": @@ -1595,10 +1615,12 @@ const deserializeAws_json1_1ValidateResourcePolicyCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2744,7 +2766,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2770,6 +2792,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-securityhub/src/protocols/Aws_restJson1.ts b/clients/client-securityhub/src/protocols/Aws_restJson1.ts index cdac0ac4d7716..8ef9193453d75 100644 --- a/clients/client-securityhub/src/protocols/Aws_restJson1.ts +++ b/clients/client-securityhub/src/protocols/Aws_restJson1.ts @@ -2268,8 +2268,7 @@ const deserializeAws_restJson1AcceptAdministratorInvitationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2288,10 +2287,12 @@ const deserializeAws_restJson1AcceptAdministratorInvitationCommandError = async throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2320,8 +2321,7 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2340,10 +2340,12 @@ const deserializeAws_restJson1AcceptInvitationCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2379,8 +2381,7 @@ const deserializeAws_restJson1BatchDisableStandardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2396,10 +2397,12 @@ const deserializeAws_restJson1BatchDisableStandardsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2435,8 +2438,7 @@ const deserializeAws_restJson1BatchEnableStandardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2452,10 +2454,12 @@ const deserializeAws_restJson1BatchEnableStandardsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2496,8 +2500,7 @@ const deserializeAws_restJson1BatchImportFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2513,10 +2516,12 @@ const deserializeAws_restJson1BatchImportFindingsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2564,7 @@ const deserializeAws_restJson1BatchUpdateFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2576,10 +2580,12 @@ const deserializeAws_restJson1BatchUpdateFindingsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2612,8 +2618,7 @@ const deserializeAws_restJson1CreateActionTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2632,10 +2637,12 @@ const deserializeAws_restJson1CreateActionTargetCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2680,8 +2687,7 @@ const deserializeAws_restJson1CreateFindingAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -2700,10 +2706,12 @@ const deserializeAws_restJson1CreateFindingAggregatorCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2736,8 +2744,7 @@ const deserializeAws_restJson1CreateInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2756,10 +2763,12 @@ const deserializeAws_restJson1CreateInsightCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2792,8 +2801,7 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2812,10 +2820,12 @@ const deserializeAws_restJson1CreateMembersCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2848,8 +2858,7 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2865,10 +2874,12 @@ const deserializeAws_restJson1DeclineInvitationsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2901,8 +2912,7 @@ const deserializeAws_restJson1DeleteActionTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -2918,10 +2928,12 @@ const deserializeAws_restJson1DeleteActionTargetCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2950,8 +2962,7 @@ const deserializeAws_restJson1DeleteFindingAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -2973,10 +2984,12 @@ const deserializeAws_restJson1DeleteFindingAggregatorCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3009,8 +3022,7 @@ const deserializeAws_restJson1DeleteInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3029,10 +3041,12 @@ const deserializeAws_restJson1DeleteInsightCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3065,8 +3079,7 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3085,10 +3098,12 @@ const deserializeAws_restJson1DeleteInvitationsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3121,8 +3136,7 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3141,10 +3155,12 @@ const deserializeAws_restJson1DeleteMembersCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3181,8 +3197,7 @@ const deserializeAws_restJson1DescribeActionTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3198,10 +3213,12 @@ const deserializeAws_restJson1DescribeActionTargetsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3242,8 +3259,7 @@ const deserializeAws_restJson1DescribeHubCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3262,10 +3278,12 @@ const deserializeAws_restJson1DescribeHubCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3306,8 +3324,7 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3323,10 +3340,12 @@ const deserializeAws_restJson1DescribeOrganizationConfigurationCommandError = as throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3363,8 +3382,7 @@ const deserializeAws_restJson1DescribeProductsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3380,10 +3398,12 @@ const deserializeAws_restJson1DescribeProductsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3420,8 +3440,7 @@ const deserializeAws_restJson1DescribeStandardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3434,10 +3453,12 @@ const deserializeAws_restJson1DescribeStandardsCommandError = async ( throw await deserializeAws_restJson1InvalidInputExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3474,8 +3495,7 @@ const deserializeAws_restJson1DescribeStandardsControlsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3491,10 +3511,12 @@ const deserializeAws_restJson1DescribeStandardsControlsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3523,8 +3545,7 @@ const deserializeAws_restJson1DisableImportFindingsForProductCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3543,10 +3564,12 @@ const deserializeAws_restJson1DisableImportFindingsForProductCommandError = asyn throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3575,8 +3598,7 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3592,10 +3614,12 @@ const deserializeAws_restJson1DisableOrganizationAdminAccountCommandError = asyn throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3624,8 +3648,7 @@ const deserializeAws_restJson1DisableSecurityHubCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3641,10 +3664,12 @@ const deserializeAws_restJson1DisableSecurityHubCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3673,8 +3698,7 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3693,10 +3717,12 @@ const deserializeAws_restJson1DisassociateFromAdministratorAccountCommandError = throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3725,8 +3751,7 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3745,10 +3770,12 @@ const deserializeAws_restJson1DisassociateFromMasterAccountCommandError = async throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3777,8 +3804,7 @@ const deserializeAws_restJson1DisassociateMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3797,10 +3823,12 @@ const deserializeAws_restJson1DisassociateMembersCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3833,8 +3861,7 @@ const deserializeAws_restJson1EnableImportFindingsForProductCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3853,10 +3880,12 @@ const deserializeAws_restJson1EnableImportFindingsForProductCommandError = async throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3885,8 +3914,7 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -3902,10 +3930,12 @@ const deserializeAws_restJson1EnableOrganizationAdminAccountCommandError = async throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3934,8 +3964,7 @@ const deserializeAws_restJson1EnableSecurityHubCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -3954,10 +3983,12 @@ const deserializeAws_restJson1EnableSecurityHubCommandError = async ( throw await deserializeAws_restJson1ResourceConflictExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3990,8 +4021,7 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4010,10 +4040,12 @@ const deserializeAws_restJson1GetAdministratorAccountCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4053,8 +4085,7 @@ const deserializeAws_restJson1GetEnabledStandardsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4070,10 +4101,12 @@ const deserializeAws_restJson1GetEnabledStandardsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4118,8 +4151,7 @@ const deserializeAws_restJson1GetFindingAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -4141,10 +4173,12 @@ const deserializeAws_restJson1GetFindingAggregatorCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4181,8 +4215,7 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4198,10 +4231,12 @@ const deserializeAws_restJson1GetFindingsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4234,8 +4269,7 @@ const deserializeAws_restJson1GetInsightResultsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4254,10 +4288,12 @@ const deserializeAws_restJson1GetInsightResultsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4294,8 +4330,7 @@ const deserializeAws_restJson1GetInsightsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4314,10 +4349,12 @@ const deserializeAws_restJson1GetInsightsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4350,8 +4387,7 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4367,10 +4403,12 @@ const deserializeAws_restJson1GetInvitationsCountCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4403,8 +4441,7 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4423,10 +4460,12 @@ const deserializeAws_restJson1GetMasterAccountCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4463,8 +4502,7 @@ const deserializeAws_restJson1GetMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4483,10 +4521,12 @@ const deserializeAws_restJson1GetMembersCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4519,8 +4559,7 @@ const deserializeAws_restJson1InviteMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4539,10 +4578,12 @@ const deserializeAws_restJson1InviteMembersCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4582,8 +4623,7 @@ const deserializeAws_restJson1ListEnabledProductsForImportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4596,10 +4636,12 @@ const deserializeAws_restJson1ListEnabledProductsForImportCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4636,8 +4678,7 @@ const deserializeAws_restJson1ListFindingAggregatorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -4656,10 +4697,12 @@ const deserializeAws_restJson1ListFindingAggregatorsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4696,8 +4739,7 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4713,10 +4755,12 @@ const deserializeAws_restJson1ListInvitationsCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4753,8 +4797,7 @@ const deserializeAws_restJson1ListMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4770,10 +4813,12 @@ const deserializeAws_restJson1ListMembersCommandError = async ( throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4810,8 +4855,7 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4827,10 +4871,12 @@ const deserializeAws_restJson1ListOrganizationAdminAccountsCommandError = async throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4863,8 +4909,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4877,10 +4922,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4909,8 +4956,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4923,10 +4969,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4955,8 +5003,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -4969,10 +5016,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5001,8 +5050,7 @@ const deserializeAws_restJson1UpdateActionTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5018,10 +5066,12 @@ const deserializeAws_restJson1UpdateActionTargetCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5066,8 +5116,7 @@ const deserializeAws_restJson1UpdateFindingAggregatorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.securityhub#AccessDeniedException": @@ -5089,10 +5138,12 @@ const deserializeAws_restJson1UpdateFindingAggregatorCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5121,8 +5172,7 @@ const deserializeAws_restJson1UpdateFindingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5141,10 +5191,12 @@ const deserializeAws_restJson1UpdateFindingsCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5173,8 +5225,7 @@ const deserializeAws_restJson1UpdateInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5193,10 +5244,12 @@ const deserializeAws_restJson1UpdateInsightCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5225,8 +5278,7 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5242,10 +5294,12 @@ const deserializeAws_restJson1UpdateOrganizationConfigurationCommandError = asyn throw await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5274,8 +5328,7 @@ const deserializeAws_restJson1UpdateSecurityHubConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5294,10 +5347,12 @@ const deserializeAws_restJson1UpdateSecurityHubConfigurationCommandError = async throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5326,8 +5381,7 @@ const deserializeAws_restJson1UpdateStandardsControlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalException": case "com.amazonaws.securityhub#InternalException": @@ -5343,10 +5397,12 @@ const deserializeAws_restJson1UpdateStandardsControlCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -27615,7 +27671,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -27641,6 +27697,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-serverlessapplicationrepository/src/protocols/Aws_restJson1.ts b/clients/client-serverlessapplicationrepository/src/protocols/Aws_restJson1.ts index 4fd2c336f2995..c44cfe47a50da 100644 --- a/clients/client-serverlessapplicationrepository/src/protocols/Aws_restJson1.ts +++ b/clients/client-serverlessapplicationrepository/src/protocols/Aws_restJson1.ts @@ -671,8 +671,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -691,10 +690,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -762,8 +763,7 @@ const deserializeAws_restJson1CreateApplicationVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -782,10 +782,12 @@ const deserializeAws_restJson1CreateApplicationVersionCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -830,8 +832,7 @@ const deserializeAws_restJson1CreateCloudFormationChangeSetCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -847,10 +848,12 @@ const deserializeAws_restJson1CreateCloudFormationChangeSetCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -907,8 +910,7 @@ const deserializeAws_restJson1CreateCloudFormationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -927,10 +929,12 @@ const deserializeAws_restJson1CreateCloudFormationTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -959,8 +963,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -982,10 +985,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1066,8 +1071,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1086,10 +1090,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1122,8 +1128,7 @@ const deserializeAws_restJson1GetApplicationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1142,10 +1147,12 @@ const deserializeAws_restJson1GetApplicationPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1202,8 +1209,7 @@ const deserializeAws_restJson1GetCloudFormationTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1222,10 +1228,12 @@ const deserializeAws_restJson1GetCloudFormationTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1262,8 +1270,7 @@ const deserializeAws_restJson1ListApplicationDependenciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1282,10 +1289,12 @@ const deserializeAws_restJson1ListApplicationDependenciesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1331,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1339,10 +1347,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1379,8 +1389,7 @@ const deserializeAws_restJson1ListApplicationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1399,10 +1408,12 @@ const deserializeAws_restJson1ListApplicationVersionsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1435,8 +1446,7 @@ const deserializeAws_restJson1PutApplicationPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1455,10 +1465,12 @@ const deserializeAws_restJson1PutApplicationPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1487,8 +1499,7 @@ const deserializeAws_restJson1UnshareApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1507,10 +1518,12 @@ const deserializeAws_restJson1UnshareApplicationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1591,8 +1604,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.serverlessapplicationrepository#BadRequestException": @@ -1614,10 +1626,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2077,7 +2091,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2103,6 +2117,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-service-catalog-appregistry/src/protocols/Aws_restJson1.ts b/clients/client-service-catalog-appregistry/src/protocols/Aws_restJson1.ts index ad63e23771ada..1d59980364d6d 100644 --- a/clients/client-service-catalog-appregistry/src/protocols/Aws_restJson1.ts +++ b/clients/client-service-catalog-appregistry/src/protocols/Aws_restJson1.ts @@ -871,8 +871,7 @@ const deserializeAws_restJson1AssociateAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -891,10 +890,12 @@ const deserializeAws_restJson1AssociateAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -931,8 +932,7 @@ const deserializeAws_restJson1AssociateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -951,10 +951,12 @@ const deserializeAws_restJson1AssociateResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -987,8 +989,7 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -1004,10 +1005,12 @@ const deserializeAws_restJson1CreateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1040,8 +1043,7 @@ const deserializeAws_restJson1CreateAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -1057,10 +1059,12 @@ const deserializeAws_restJson1CreateAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1097,7 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1107,10 +1110,12 @@ const deserializeAws_restJson1DeleteApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1143,8 +1148,7 @@ const deserializeAws_restJson1DeleteAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1157,10 +1161,12 @@ const deserializeAws_restJson1DeleteAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1197,8 +1203,7 @@ const deserializeAws_restJson1DisassociateAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1211,10 +1216,12 @@ const deserializeAws_restJson1DisassociateAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1251,8 +1258,7 @@ const deserializeAws_restJson1DisassociateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1265,10 +1271,12 @@ const deserializeAws_restJson1DisassociateResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1333,8 +1341,7 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -1350,10 +1357,12 @@ const deserializeAws_restJson1GetApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1386,8 +1395,7 @@ const deserializeAws_restJson1GetAssociatedResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1400,10 +1408,12 @@ const deserializeAws_restJson1GetAssociatedResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1464,8 +1474,7 @@ const deserializeAws_restJson1GetAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -1481,10 +1490,12 @@ const deserializeAws_restJson1GetAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1521,8 +1532,7 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1532,10 +1542,12 @@ const deserializeAws_restJson1ListApplicationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1572,8 +1584,7 @@ const deserializeAws_restJson1ListAssociatedAttributeGroupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1586,10 +1597,12 @@ const deserializeAws_restJson1ListAssociatedAttributeGroupsCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1626,8 +1639,7 @@ const deserializeAws_restJson1ListAssociatedResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1640,10 +1652,12 @@ const deserializeAws_restJson1ListAssociatedResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1680,8 +1694,7 @@ const deserializeAws_restJson1ListAttributeGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1691,10 +1704,12 @@ const deserializeAws_restJson1ListAttributeGroupsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1734,8 +1749,7 @@ const deserializeAws_restJson1ListAttributeGroupsForApplicationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1748,10 +1762,12 @@ const deserializeAws_restJson1ListAttributeGroupsForApplicationCommandError = as throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1784,8 +1800,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1798,10 +1813,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1842,8 +1859,7 @@ const deserializeAws_restJson1SyncResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -1856,10 +1872,12 @@ const deserializeAws_restJson1SyncResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1888,8 +1906,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1902,10 +1919,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1934,8 +1953,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.servicecatalogappregistry#InternalServerException": @@ -1948,10 +1966,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1984,8 +2004,7 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -2001,10 +2020,12 @@ const deserializeAws_restJson1UpdateApplicationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2037,8 +2058,7 @@ const deserializeAws_restJson1UpdateAttributeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.servicecatalogappregistry#ConflictException": @@ -2054,10 +2074,12 @@ const deserializeAws_restJson1UpdateAttributeGroupCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2402,7 +2424,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2428,6 +2450,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-service-catalog/src/protocols/Aws_json1_1.ts b/clients/client-service-catalog/src/protocols/Aws_json1_1.ts index 67ca43493ef9c..53806fb2662a7 100644 --- a/clients/client-service-catalog/src/protocols/Aws_json1_1.ts +++ b/clients/client-service-catalog/src/protocols/Aws_json1_1.ts @@ -1695,8 +1695,7 @@ const deserializeAws_json1_1AcceptPortfolioShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -1709,10 +1708,12 @@ const deserializeAws_json1_1AcceptPortfolioShareCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1744,8 +1745,7 @@ const deserializeAws_json1_1AssociateBudgetWithResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -1761,10 +1761,12 @@ const deserializeAws_json1_1AssociateBudgetWithResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1796,8 +1798,7 @@ const deserializeAws_json1_1AssociatePrincipalWithPortfolioCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -1810,10 +1811,12 @@ const deserializeAws_json1_1AssociatePrincipalWithPortfolioCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1845,8 +1848,7 @@ const deserializeAws_json1_1AssociateProductWithPortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -1859,10 +1861,12 @@ const deserializeAws_json1_1AssociateProductWithPortfolioCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1894,8 +1898,7 @@ const deserializeAws_json1_1AssociateServiceActionWithProvisioningArtifactComman body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -1908,10 +1911,12 @@ const deserializeAws_json1_1AssociateServiceActionWithProvisioningArtifactComman throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1943,8 +1948,7 @@ const deserializeAws_json1_1AssociateTagOptionWithResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -1966,10 +1970,12 @@ const deserializeAws_json1_1AssociateTagOptionWithResourceCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2001,18 +2007,19 @@ const deserializeAws_json1_1BatchAssociateServiceActionWithProvisioningArtifactC body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,18 +2051,19 @@ const deserializeAws_json1_1BatchDisassociateServiceActionFromProvisioningArtifa body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2087,8 +2095,7 @@ const deserializeAws_json1_1CopyProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2098,10 +2105,12 @@ const deserializeAws_json1_1CopyProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2133,8 +2142,7 @@ const deserializeAws_json1_1CreateConstraintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -2150,10 +2158,12 @@ const deserializeAws_json1_1CreateConstraintCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2185,8 +2195,7 @@ const deserializeAws_json1_1CreatePortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2199,10 +2208,12 @@ const deserializeAws_json1_1CreatePortfolioCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2234,8 +2245,7 @@ const deserializeAws_json1_1CreatePortfolioShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2254,10 +2264,12 @@ const deserializeAws_json1_1CreatePortfolioShareCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2289,8 +2301,7 @@ const deserializeAws_json1_1CreateProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2303,10 +2314,12 @@ const deserializeAws_json1_1CreateProductCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2338,8 +2351,7 @@ const deserializeAws_json1_1CreateProvisionedProductPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2352,10 +2364,12 @@ const deserializeAws_json1_1CreateProvisionedProductPlanCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2387,8 +2401,7 @@ const deserializeAws_json1_1CreateProvisioningArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2401,10 +2414,12 @@ const deserializeAws_json1_1CreateProvisioningArtifactCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2436,8 +2451,7 @@ const deserializeAws_json1_1CreateServiceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2447,10 +2461,12 @@ const deserializeAws_json1_1CreateServiceActionCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2482,8 +2498,7 @@ const deserializeAws_json1_1CreateTagOptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -2496,10 +2511,12 @@ const deserializeAws_json1_1CreateTagOptionCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2531,8 +2548,7 @@ const deserializeAws_json1_1DeleteConstraintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2542,10 +2558,12 @@ const deserializeAws_json1_1DeleteConstraintCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2577,8 +2595,7 @@ const deserializeAws_json1_1DeletePortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2594,10 +2611,12 @@ const deserializeAws_json1_1DeletePortfolioCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2629,8 +2648,7 @@ const deserializeAws_json1_1DeletePortfolioShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2646,10 +2664,12 @@ const deserializeAws_json1_1DeletePortfolioShareCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2681,8 +2701,7 @@ const deserializeAws_json1_1DeleteProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2698,10 +2717,12 @@ const deserializeAws_json1_1DeleteProductCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2733,8 +2754,7 @@ const deserializeAws_json1_1DeleteProvisionedProductPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2744,10 +2764,12 @@ const deserializeAws_json1_1DeleteProvisionedProductPlanCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2779,8 +2801,7 @@ const deserializeAws_json1_1DeleteProvisioningArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -2793,10 +2814,12 @@ const deserializeAws_json1_1DeleteProvisioningArtifactCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2828,8 +2851,7 @@ const deserializeAws_json1_1DeleteServiceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.servicecatalog#ResourceInUseException": @@ -2839,10 +2861,12 @@ const deserializeAws_json1_1DeleteServiceActionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2874,8 +2898,7 @@ const deserializeAws_json1_1DeleteTagOptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceInUseException": case "com.amazonaws.servicecatalog#ResourceInUseException": @@ -2888,10 +2911,12 @@ const deserializeAws_json1_1DeleteTagOptionCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2923,18 +2948,19 @@ const deserializeAws_json1_1DescribeConstraintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2966,18 +2992,19 @@ const deserializeAws_json1_1DescribeCopyProductStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3009,18 +3036,19 @@ const deserializeAws_json1_1DescribePortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3052,8 +3080,7 @@ const deserializeAws_json1_1DescribePortfolioSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3063,10 +3090,12 @@ const deserializeAws_json1_1DescribePortfolioSharesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3098,8 +3127,7 @@ const deserializeAws_json1_1DescribePortfolioShareStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3112,10 +3140,12 @@ const deserializeAws_json1_1DescribePortfolioShareStatusCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3147,8 +3177,7 @@ const deserializeAws_json1_1DescribeProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3158,10 +3187,12 @@ const deserializeAws_json1_1DescribeProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3193,8 +3224,7 @@ const deserializeAws_json1_1DescribeProductAsAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3204,10 +3234,12 @@ const deserializeAws_json1_1DescribeProductAsAdminCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3239,8 +3271,7 @@ const deserializeAws_json1_1DescribeProductViewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3250,10 +3281,12 @@ const deserializeAws_json1_1DescribeProductViewCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3285,8 +3318,7 @@ const deserializeAws_json1_1DescribeProvisionedProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3296,10 +3328,12 @@ const deserializeAws_json1_1DescribeProvisionedProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3331,8 +3365,7 @@ const deserializeAws_json1_1DescribeProvisionedProductPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3342,10 +3375,12 @@ const deserializeAws_json1_1DescribeProvisionedProductPlanCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3377,8 +3412,7 @@ const deserializeAws_json1_1DescribeProvisioningArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3388,10 +3422,12 @@ const deserializeAws_json1_1DescribeProvisioningArtifactCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3423,8 +3459,7 @@ const deserializeAws_json1_1DescribeProvisioningParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3434,10 +3469,12 @@ const deserializeAws_json1_1DescribeProvisioningParametersCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3469,18 +3506,19 @@ const deserializeAws_json1_1DescribeRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3512,18 +3550,19 @@ const deserializeAws_json1_1DescribeServiceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3555,8 +3594,7 @@ const deserializeAws_json1_1DescribeServiceActionExecutionParametersCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3566,10 +3604,12 @@ const deserializeAws_json1_1DescribeServiceActionExecutionParametersCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3601,8 +3641,7 @@ const deserializeAws_json1_1DescribeTagOptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": @@ -3612,10 +3651,12 @@ const deserializeAws_json1_1DescribeTagOptionCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3647,8 +3688,7 @@ const deserializeAws_json1_1DisableAWSOrganizationsAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.servicecatalog#InvalidStateException": @@ -3661,10 +3701,12 @@ const deserializeAws_json1_1DisableAWSOrganizationsAccessCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3696,18 +3738,19 @@ const deserializeAws_json1_1DisassociateBudgetFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3739,8 +3782,7 @@ const deserializeAws_json1_1DisassociatePrincipalFromPortfolioCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3750,10 +3792,12 @@ const deserializeAws_json1_1DisassociatePrincipalFromPortfolioCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3785,8 +3829,7 @@ const deserializeAws_json1_1DisassociateProductFromPortfolioCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3799,10 +3842,12 @@ const deserializeAws_json1_1DisassociateProductFromPortfolioCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3834,18 +3879,19 @@ const deserializeAws_json1_1DisassociateServiceActionFromProvisioningArtifactCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3877,8 +3923,7 @@ const deserializeAws_json1_1DisassociateTagOptionFromResourceCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": @@ -3888,10 +3933,12 @@ const deserializeAws_json1_1DisassociateTagOptionFromResourceCommandError = asyn throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3923,8 +3970,7 @@ const deserializeAws_json1_1EnableAWSOrganizationsAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidStateException": case "com.amazonaws.servicecatalog#InvalidStateException": @@ -3937,10 +3983,12 @@ const deserializeAws_json1_1EnableAWSOrganizationsAccessCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3972,8 +4020,7 @@ const deserializeAws_json1_1ExecuteProvisionedProductPlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -3986,10 +4033,12 @@ const deserializeAws_json1_1ExecuteProvisionedProductPlanCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4021,8 +4070,7 @@ const deserializeAws_json1_1ExecuteProvisionedProductServiceActionCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4035,10 +4083,12 @@ const deserializeAws_json1_1ExecuteProvisionedProductServiceActionCommandError = throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4070,8 +4120,7 @@ const deserializeAws_json1_1GetAWSOrganizationsAccessStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotSupportedException": case "com.amazonaws.servicecatalog#OperationNotSupportedException": @@ -4081,10 +4130,12 @@ const deserializeAws_json1_1GetAWSOrganizationsAccessStatusCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4116,8 +4167,7 @@ const deserializeAws_json1_1GetProvisionedProductOutputsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4127,10 +4177,12 @@ const deserializeAws_json1_1GetProvisionedProductOutputsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4162,8 +4214,7 @@ const deserializeAws_json1_1ImportAsProvisionedProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -4179,10 +4230,12 @@ const deserializeAws_json1_1ImportAsProvisionedProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4214,8 +4267,7 @@ const deserializeAws_json1_1ListAcceptedPortfolioSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4225,10 +4277,12 @@ const deserializeAws_json1_1ListAcceptedPortfolioSharesCommandError = async ( throw await deserializeAws_json1_1OperationNotSupportedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4260,8 +4314,7 @@ const deserializeAws_json1_1ListBudgetsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4271,10 +4324,12 @@ const deserializeAws_json1_1ListBudgetsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4306,8 +4361,7 @@ const deserializeAws_json1_1ListConstraintsForPortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4317,10 +4371,12 @@ const deserializeAws_json1_1ListConstraintsForPortfolioCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4352,8 +4408,7 @@ const deserializeAws_json1_1ListLaunchPathsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4363,10 +4418,12 @@ const deserializeAws_json1_1ListLaunchPathsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4398,8 +4455,7 @@ const deserializeAws_json1_1ListOrganizationPortfolioAccessCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4412,10 +4468,12 @@ const deserializeAws_json1_1ListOrganizationPortfolioAccessCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4447,8 +4505,7 @@ const deserializeAws_json1_1ListPortfolioAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4458,10 +4515,12 @@ const deserializeAws_json1_1ListPortfolioAccessCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4493,18 +4552,19 @@ const deserializeAws_json1_1ListPortfoliosCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4536,8 +4596,7 @@ const deserializeAws_json1_1ListPortfoliosForProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4547,10 +4606,12 @@ const deserializeAws_json1_1ListPortfoliosForProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4582,8 +4643,7 @@ const deserializeAws_json1_1ListPrincipalsForPortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4593,10 +4653,12 @@ const deserializeAws_json1_1ListPrincipalsForPortfolioCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4628,8 +4690,7 @@ const deserializeAws_json1_1ListProvisionedProductPlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4639,10 +4700,12 @@ const deserializeAws_json1_1ListProvisionedProductPlansCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4674,8 +4737,7 @@ const deserializeAws_json1_1ListProvisioningArtifactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4685,10 +4747,12 @@ const deserializeAws_json1_1ListProvisioningArtifactsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4720,8 +4784,7 @@ const deserializeAws_json1_1ListProvisioningArtifactsForServiceActionCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4731,10 +4794,12 @@ const deserializeAws_json1_1ListProvisioningArtifactsForServiceActionCommandErro throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4766,18 +4831,19 @@ const deserializeAws_json1_1ListRecordHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4809,8 +4875,7 @@ const deserializeAws_json1_1ListResourcesForTagOptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4823,10 +4888,12 @@ const deserializeAws_json1_1ListResourcesForTagOptionCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4858,18 +4925,19 @@ const deserializeAws_json1_1ListServiceActionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4901,8 +4969,7 @@ const deserializeAws_json1_1ListServiceActionsForProvisioningArtifactCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4912,10 +4979,12 @@ const deserializeAws_json1_1ListServiceActionsForProvisioningArtifactCommandErro throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4947,8 +5016,7 @@ const deserializeAws_json1_1ListStackInstancesForProvisionedProductCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -4958,10 +5026,12 @@ const deserializeAws_json1_1ListStackInstancesForProvisionedProductCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4993,8 +5063,7 @@ const deserializeAws_json1_1ListTagOptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5004,10 +5073,12 @@ const deserializeAws_json1_1ListTagOptionsCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5039,8 +5110,7 @@ const deserializeAws_json1_1ProvisionProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -5053,10 +5123,12 @@ const deserializeAws_json1_1ProvisionProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5088,18 +5160,19 @@ const deserializeAws_json1_1RejectPortfolioShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5131,18 +5204,19 @@ const deserializeAws_json1_1ScanProvisionedProductsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5174,18 +5248,19 @@ const deserializeAws_json1_1SearchProductsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5217,8 +5292,7 @@ const deserializeAws_json1_1SearchProductsAsAdminCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5228,10 +5302,12 @@ const deserializeAws_json1_1SearchProductsAsAdminCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5263,18 +5339,19 @@ const deserializeAws_json1_1SearchProvisionedProductsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": throw await deserializeAws_json1_1InvalidParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5306,18 +5383,19 @@ const deserializeAws_json1_1TerminateProvisionedProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.servicecatalog#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5349,8 +5427,7 @@ const deserializeAws_json1_1UpdateConstraintCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5360,10 +5437,12 @@ const deserializeAws_json1_1UpdateConstraintCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5395,8 +5474,7 @@ const deserializeAws_json1_1UpdatePortfolioCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5412,10 +5490,12 @@ const deserializeAws_json1_1UpdatePortfolioCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5447,8 +5527,7 @@ const deserializeAws_json1_1UpdatePortfolioShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5464,10 +5543,12 @@ const deserializeAws_json1_1UpdatePortfolioShareCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5499,8 +5580,7 @@ const deserializeAws_json1_1UpdateProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5513,10 +5593,12 @@ const deserializeAws_json1_1UpdateProductCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5548,8 +5630,7 @@ const deserializeAws_json1_1UpdateProvisionedProductCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5559,10 +5640,12 @@ const deserializeAws_json1_1UpdateProvisionedProductCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5594,8 +5677,7 @@ const deserializeAws_json1_1UpdateProvisionedProductPropertiesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5608,10 +5690,12 @@ const deserializeAws_json1_1UpdateProvisionedProductPropertiesCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5643,8 +5727,7 @@ const deserializeAws_json1_1UpdateProvisioningArtifactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5654,10 +5737,12 @@ const deserializeAws_json1_1UpdateProvisioningArtifactCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5689,8 +5774,7 @@ const deserializeAws_json1_1UpdateServiceActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParametersException": case "com.amazonaws.servicecatalog#InvalidParametersException": @@ -5700,10 +5784,12 @@ const deserializeAws_json1_1UpdateServiceActionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5735,8 +5821,7 @@ const deserializeAws_json1_1UpdateTagOptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateResourceException": case "com.amazonaws.servicecatalog#DuplicateResourceException": @@ -5752,10 +5837,12 @@ const deserializeAws_json1_1UpdateTagOptionCommandError = async ( throw await deserializeAws_json1_1TagOptionNotMigratedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9900,7 +9987,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9926,6 +10013,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-service-quotas/src/protocols/Aws_json1_1.ts b/clients/client-service-quotas/src/protocols/Aws_json1_1.ts index 1bc5e41fb6b01..2062496ffc987 100644 --- a/clients/client-service-quotas/src/protocols/Aws_json1_1.ts +++ b/clients/client-service-quotas/src/protocols/Aws_json1_1.ts @@ -419,8 +419,7 @@ const deserializeAws_json1_1AssociateServiceQuotaTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -448,10 +447,12 @@ const deserializeAws_json1_1AssociateServiceQuotaTemplateCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -483,8 +484,7 @@ const deserializeAws_json1_1DeleteServiceQuotaIncreaseRequestFromTemplateCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -515,10 +515,12 @@ const deserializeAws_json1_1DeleteServiceQuotaIncreaseRequestFromTemplateCommand throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -550,8 +552,7 @@ const deserializeAws_json1_1DisassociateServiceQuotaTemplateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -579,10 +580,12 @@ const deserializeAws_json1_1DisassociateServiceQuotaTemplateCommandError = async throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -614,8 +617,7 @@ const deserializeAws_json1_1GetAssociationForServiceQuotaTemplateCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -643,10 +645,12 @@ const deserializeAws_json1_1GetAssociationForServiceQuotaTemplateCommandError = throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -678,8 +682,7 @@ const deserializeAws_json1_1GetAWSDefaultServiceQuotaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -698,10 +701,12 @@ const deserializeAws_json1_1GetAWSDefaultServiceQuotaCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -733,8 +738,7 @@ const deserializeAws_json1_1GetRequestedServiceQuotaChangeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -753,10 +757,12 @@ const deserializeAws_json1_1GetRequestedServiceQuotaChangeCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -788,8 +794,7 @@ const deserializeAws_json1_1GetServiceQuotaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -808,10 +813,12 @@ const deserializeAws_json1_1GetServiceQuotaCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -843,8 +850,7 @@ const deserializeAws_json1_1GetServiceQuotaIncreaseRequestFromTemplateCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -875,10 +881,12 @@ const deserializeAws_json1_1GetServiceQuotaIncreaseRequestFromTemplateCommandErr throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -910,8 +918,7 @@ const deserializeAws_json1_1ListAWSDefaultServiceQuotasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -933,10 +940,12 @@ const deserializeAws_json1_1ListAWSDefaultServiceQuotasCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -968,8 +977,7 @@ const deserializeAws_json1_1ListRequestedServiceQuotaChangeHistoryCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -991,10 +999,12 @@ const deserializeAws_json1_1ListRequestedServiceQuotaChangeHistoryCommandError = throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1026,8 +1036,7 @@ const deserializeAws_json1_1ListRequestedServiceQuotaChangeHistoryByQuotaCommand body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1049,10 +1058,12 @@ const deserializeAws_json1_1ListRequestedServiceQuotaChangeHistoryByQuotaCommand throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1084,8 +1095,7 @@ const deserializeAws_json1_1ListServiceQuotaIncreaseRequestsInTemplateCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1113,10 +1123,12 @@ const deserializeAws_json1_1ListServiceQuotaIncreaseRequestsInTemplateCommandErr throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1148,8 +1160,7 @@ const deserializeAws_json1_1ListServiceQuotasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1171,10 +1182,12 @@ const deserializeAws_json1_1ListServiceQuotasCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1219,7 @@ const deserializeAws_json1_1ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1226,10 +1238,12 @@ const deserializeAws_json1_1ListServicesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,8 +1275,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1281,10 +1294,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1316,8 +1331,7 @@ const deserializeAws_json1_1PutServiceQuotaIncreaseRequestIntoTemplateCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1351,10 +1365,12 @@ const deserializeAws_json1_1PutServiceQuotaIncreaseRequestIntoTemplateCommandErr throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1386,8 +1402,7 @@ const deserializeAws_json1_1RequestServiceQuotaIncreaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1418,10 +1433,12 @@ const deserializeAws_json1_1RequestServiceQuotaIncreaseCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,8 +1470,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1479,10 +1495,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1514,8 +1532,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.servicequotas#AccessDeniedException": @@ -1534,10 +1551,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2574,7 +2593,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2600,6 +2619,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-servicediscovery/src/protocols/Aws_json1_1.ts b/clients/client-servicediscovery/src/protocols/Aws_json1_1.ts index e748032035b0f..3ce51eccec3d2 100644 --- a/clients/client-servicediscovery/src/protocols/Aws_json1_1.ts +++ b/clients/client-servicediscovery/src/protocols/Aws_json1_1.ts @@ -551,8 +551,7 @@ const deserializeAws_json1_1CreateHttpNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -571,10 +570,12 @@ const deserializeAws_json1_1CreateHttpNamespaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -606,8 +607,7 @@ const deserializeAws_json1_1CreatePrivateDnsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -626,10 +626,12 @@ const deserializeAws_json1_1CreatePrivateDnsNamespaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -661,8 +663,7 @@ const deserializeAws_json1_1CreatePublicDnsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -681,10 +682,12 @@ const deserializeAws_json1_1CreatePublicDnsNamespaceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -716,8 +719,7 @@ const deserializeAws_json1_1CreateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -736,10 +738,12 @@ const deserializeAws_json1_1CreateServiceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -771,8 +775,7 @@ const deserializeAws_json1_1DeleteNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -788,10 +791,12 @@ const deserializeAws_json1_1DeleteNamespaceCommandError = async ( throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -823,8 +828,7 @@ const deserializeAws_json1_1DeleteServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -837,10 +841,12 @@ const deserializeAws_json1_1DeleteServiceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -872,8 +878,7 @@ const deserializeAws_json1_1DeregisterInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -892,10 +897,12 @@ const deserializeAws_json1_1DeregisterInstanceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -927,8 +934,7 @@ const deserializeAws_json1_1DiscoverInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -944,10 +950,12 @@ const deserializeAws_json1_1DiscoverInstancesCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -979,8 +987,7 @@ const deserializeAws_json1_1GetInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceNotFound": case "com.amazonaws.servicediscovery#InstanceNotFound": @@ -993,10 +1000,12 @@ const deserializeAws_json1_1GetInstanceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1028,8 +1037,7 @@ const deserializeAws_json1_1GetInstancesHealthStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InstanceNotFound": case "com.amazonaws.servicediscovery#InstanceNotFound": @@ -1042,10 +1050,12 @@ const deserializeAws_json1_1GetInstancesHealthStatusCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1077,8 +1087,7 @@ const deserializeAws_json1_1GetNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1088,10 +1097,12 @@ const deserializeAws_json1_1GetNamespaceCommandError = async ( throw await deserializeAws_json1_1NamespaceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1123,8 +1134,7 @@ const deserializeAws_json1_1GetOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1134,10 +1144,12 @@ const deserializeAws_json1_1GetOperationCommandError = async ( throw await deserializeAws_json1_1OperationNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1169,8 +1181,7 @@ const deserializeAws_json1_1GetServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1180,10 +1191,12 @@ const deserializeAws_json1_1GetServiceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1215,8 +1228,7 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1226,10 +1238,12 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,18 +1275,19 @@ const deserializeAws_json1_1ListNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,18 +1319,19 @@ const deserializeAws_json1_1ListOperationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1347,18 +1363,19 @@ const deserializeAws_json1_1ListServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": throw await deserializeAws_json1_1InvalidInputResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1390,8 +1407,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1401,10 +1417,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1436,8 +1454,7 @@ const deserializeAws_json1_1RegisterInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -1456,10 +1473,12 @@ const deserializeAws_json1_1RegisterInstanceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1491,8 +1510,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1505,10 +1523,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1540,8 +1560,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidInput": case "com.amazonaws.servicediscovery#InvalidInput": @@ -1551,10 +1570,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1586,8 +1607,7 @@ const deserializeAws_json1_1UpdateHttpNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -1603,10 +1623,12 @@ const deserializeAws_json1_1UpdateHttpNamespaceCommandError = async ( throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1635,8 +1657,7 @@ const deserializeAws_json1_1UpdateInstanceCustomHealthStatusCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomHealthNotFound": case "com.amazonaws.servicediscovery#CustomHealthNotFound": @@ -1652,10 +1673,12 @@ const deserializeAws_json1_1UpdateInstanceCustomHealthStatusCommandError = async throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1687,8 +1710,7 @@ const deserializeAws_json1_1UpdatePrivateDnsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -1704,10 +1726,12 @@ const deserializeAws_json1_1UpdatePrivateDnsNamespaceCommandError = async ( throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1739,8 +1763,7 @@ const deserializeAws_json1_1UpdatePublicDnsNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -1756,10 +1779,12 @@ const deserializeAws_json1_1UpdatePublicDnsNamespaceCommandError = async ( throw await deserializeAws_json1_1ResourceInUseResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1791,8 +1816,7 @@ const deserializeAws_json1_1UpdateServiceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateRequest": case "com.amazonaws.servicediscovery#DuplicateRequest": @@ -1805,10 +1829,12 @@ const deserializeAws_json1_1UpdateServiceCommandError = async ( throw await deserializeAws_json1_1ServiceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3310,7 +3336,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3336,6 +3362,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ses/src/protocols/Aws_query.ts b/clients/client-ses/src/protocols/Aws_query.ts index 514b7bb934b4b..7149071c92154 100644 --- a/clients/client-ses/src/protocols/Aws_query.ts +++ b/clients/client-ses/src/protocols/Aws_query.ts @@ -1607,8 +1607,7 @@ const deserializeAws_queryCloneReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ses#AlreadyExistsException": @@ -1621,10 +1620,12 @@ const deserializeAws_queryCloneReceiptRuleSetCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1656,8 +1657,7 @@ const deserializeAws_queryCreateConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetAlreadyExistsException": case "com.amazonaws.ses#ConfigurationSetAlreadyExistsException": @@ -1670,10 +1670,12 @@ const deserializeAws_queryCreateConfigurationSetCommandError = async ( throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1708,8 +1710,7 @@ const deserializeAws_queryCreateConfigurationSetEventDestinationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -1731,10 +1732,12 @@ const deserializeAws_queryCreateConfigurationSetEventDestinationCommandError = a throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1769,8 +1772,7 @@ const deserializeAws_queryCreateConfigurationSetTrackingOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -1783,10 +1785,12 @@ const deserializeAws_queryCreateConfigurationSetTrackingOptionsCommandError = as throw await deserializeAws_queryTrackingOptionsAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1815,8 +1819,7 @@ const deserializeAws_queryCreateCustomVerificationEmailTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomVerificationEmailInvalidContentException": case "com.amazonaws.ses#CustomVerificationEmailInvalidContentException": @@ -1835,10 +1838,12 @@ const deserializeAws_queryCreateCustomVerificationEmailTemplateCommandError = as throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1870,8 +1875,7 @@ const deserializeAws_queryCreateReceiptFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ses#AlreadyExistsException": @@ -1881,10 +1885,12 @@ const deserializeAws_queryCreateReceiptFilterCommandError = async ( throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1916,8 +1922,7 @@ const deserializeAws_queryCreateReceiptRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ses#AlreadyExistsException": @@ -1942,10 +1947,12 @@ const deserializeAws_queryCreateReceiptRuleCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1977,8 +1984,7 @@ const deserializeAws_queryCreateReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ses#AlreadyExistsException": @@ -1988,10 +1994,12 @@ const deserializeAws_queryCreateReceiptRuleSetCommandError = async ( throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2023,8 +2031,7 @@ const deserializeAws_queryCreateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ses#AlreadyExistsException": @@ -2037,10 +2044,12 @@ const deserializeAws_queryCreateTemplateCommandError = async ( throw await deserializeAws_queryLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2072,18 +2081,19 @@ const deserializeAws_queryDeleteConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": throw await deserializeAws_queryConfigurationSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2118,8 +2128,7 @@ const deserializeAws_queryDeleteConfigurationSetEventDestinationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -2129,10 +2138,12 @@ const deserializeAws_queryDeleteConfigurationSetEventDestinationCommandError = a throw await deserializeAws_queryEventDestinationDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2167,8 +2178,7 @@ const deserializeAws_queryDeleteConfigurationSetTrackingOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -2178,10 +2188,12 @@ const deserializeAws_queryDeleteConfigurationSetTrackingOptionsCommandError = as throw await deserializeAws_queryTrackingOptionsDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2210,15 +2222,16 @@ const deserializeAws_queryDeleteCustomVerificationEmailTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2250,15 +2263,16 @@ const deserializeAws_queryDeleteIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2290,15 +2304,16 @@ const deserializeAws_queryDeleteIdentityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2330,15 +2345,16 @@ const deserializeAws_queryDeleteReceiptFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2370,18 +2386,19 @@ const deserializeAws_queryDeleteReceiptRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleSetDoesNotExistException": case "com.amazonaws.ses#RuleSetDoesNotExistException": throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2413,18 +2430,19 @@ const deserializeAws_queryDeleteReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CannotDeleteException": case "com.amazonaws.ses#CannotDeleteException": throw await deserializeAws_queryCannotDeleteExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2456,15 +2474,16 @@ const deserializeAws_queryDeleteTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2493,15 +2512,16 @@ const deserializeAws_queryDeleteVerifiedEmailAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2533,15 +2553,16 @@ const deserializeAws_queryDescribeActiveReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2573,18 +2594,19 @@ const deserializeAws_queryDescribeConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": throw await deserializeAws_queryConfigurationSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2616,8 +2638,7 @@ const deserializeAws_queryDescribeReceiptRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleDoesNotExistException": case "com.amazonaws.ses#RuleDoesNotExistException": @@ -2627,10 +2648,12 @@ const deserializeAws_queryDescribeReceiptRuleCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2662,18 +2685,19 @@ const deserializeAws_queryDescribeReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleSetDoesNotExistException": case "com.amazonaws.ses#RuleSetDoesNotExistException": throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2705,15 +2729,16 @@ const deserializeAws_queryGetAccountSendingEnabledCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2748,8 +2773,7 @@ const deserializeAws_queryGetCustomVerificationEmailTemplateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomVerificationEmailTemplateDoesNotExistException": case "com.amazonaws.ses#CustomVerificationEmailTemplateDoesNotExistException": @@ -2759,10 +2783,12 @@ const deserializeAws_queryGetCustomVerificationEmailTemplateCommandError = async ); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2794,15 +2820,16 @@ const deserializeAws_queryGetIdentityDkimAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2837,15 +2864,16 @@ const deserializeAws_queryGetIdentityMailFromDomainAttributesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2880,15 +2908,16 @@ const deserializeAws_queryGetIdentityNotificationAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2920,15 +2949,16 @@ const deserializeAws_queryGetIdentityPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2963,15 +2993,16 @@ const deserializeAws_queryGetIdentityVerificationAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3003,15 +3034,16 @@ const deserializeAws_queryGetSendQuotaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3043,15 +3075,16 @@ const deserializeAws_queryGetSendStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3083,18 +3116,19 @@ const deserializeAws_queryGetTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "TemplateDoesNotExistException": case "com.amazonaws.ses#TemplateDoesNotExistException": throw await deserializeAws_queryTemplateDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3126,15 +3160,16 @@ const deserializeAws_queryListConfigurationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3169,15 +3204,16 @@ const deserializeAws_queryListCustomVerificationEmailTemplatesCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3209,15 +3245,16 @@ const deserializeAws_queryListIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3249,15 +3286,16 @@ const deserializeAws_queryListIdentityPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3289,15 +3327,16 @@ const deserializeAws_queryListReceiptFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3329,15 +3368,16 @@ const deserializeAws_queryListReceiptRuleSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3369,15 +3409,16 @@ const deserializeAws_queryListTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3409,15 +3450,16 @@ const deserializeAws_queryListVerifiedEmailAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3452,8 +3494,7 @@ const deserializeAws_queryPutConfigurationSetDeliveryOptionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -3463,10 +3504,12 @@ const deserializeAws_queryPutConfigurationSetDeliveryOptionsCommandError = async throw await deserializeAws_queryInvalidDeliveryOptionsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3498,18 +3541,19 @@ const deserializeAws_queryPutIdentityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidPolicyException": case "com.amazonaws.ses#InvalidPolicyException": throw await deserializeAws_queryInvalidPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3541,8 +3585,7 @@ const deserializeAws_queryReorderReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleDoesNotExistException": case "com.amazonaws.ses#RuleDoesNotExistException": @@ -3552,10 +3595,12 @@ const deserializeAws_queryReorderReceiptRuleSetCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3587,18 +3632,19 @@ const deserializeAws_querySendBounceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "MessageRejected": case "com.amazonaws.ses#MessageRejected": throw await deserializeAws_queryMessageRejectedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3630,8 +3676,7 @@ const deserializeAws_querySendBulkTemplatedEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSendingPausedException": case "com.amazonaws.ses#AccountSendingPausedException": @@ -3653,10 +3698,12 @@ const deserializeAws_querySendBulkTemplatedEmailCommandError = async ( throw await deserializeAws_queryTemplateDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3688,8 +3735,7 @@ const deserializeAws_querySendCustomVerificationEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -3711,10 +3757,12 @@ const deserializeAws_querySendCustomVerificationEmailCommandError = async ( throw await deserializeAws_queryProductionAccessNotGrantedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3746,8 +3794,7 @@ const deserializeAws_querySendEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSendingPausedException": case "com.amazonaws.ses#AccountSendingPausedException": @@ -3766,10 +3813,12 @@ const deserializeAws_querySendEmailCommandError = async ( throw await deserializeAws_queryMessageRejectedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3801,8 +3850,7 @@ const deserializeAws_querySendRawEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSendingPausedException": case "com.amazonaws.ses#AccountSendingPausedException": @@ -3821,10 +3869,12 @@ const deserializeAws_querySendRawEmailCommandError = async ( throw await deserializeAws_queryMessageRejectedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3856,8 +3906,7 @@ const deserializeAws_querySendTemplatedEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSendingPausedException": case "com.amazonaws.ses#AccountSendingPausedException": @@ -3879,10 +3928,12 @@ const deserializeAws_querySendTemplatedEmailCommandError = async ( throw await deserializeAws_queryTemplateDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3914,18 +3965,19 @@ const deserializeAws_querySetActiveReceiptRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleSetDoesNotExistException": case "com.amazonaws.ses#RuleSetDoesNotExistException": throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3957,15 +4009,16 @@ const deserializeAws_querySetIdentityDkimEnabledCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4000,15 +4053,16 @@ const deserializeAws_querySetIdentityFeedbackForwardingEnabledCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4043,15 +4097,16 @@ const deserializeAws_querySetIdentityHeadersInNotificationsEnabledCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4083,15 +4138,16 @@ const deserializeAws_querySetIdentityMailFromDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4123,15 +4179,16 @@ const deserializeAws_querySetIdentityNotificationTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4163,8 +4220,7 @@ const deserializeAws_querySetReceiptRulePositionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RuleDoesNotExistException": case "com.amazonaws.ses#RuleDoesNotExistException": @@ -4174,10 +4230,12 @@ const deserializeAws_querySetReceiptRulePositionCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4209,8 +4267,7 @@ const deserializeAws_queryTestRenderTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRenderingParameterException": case "com.amazonaws.ses#InvalidRenderingParameterException": @@ -4223,10 +4280,12 @@ const deserializeAws_queryTestRenderTemplateCommandError = async ( throw await deserializeAws_queryTemplateDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4255,15 +4314,16 @@ const deserializeAws_queryUpdateAccountSendingEnabledCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4298,8 +4358,7 @@ const deserializeAws_queryUpdateConfigurationSetEventDestinationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -4318,10 +4377,12 @@ const deserializeAws_queryUpdateConfigurationSetEventDestinationCommandError = a throw await deserializeAws_queryInvalidSNSDestinationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4350,18 +4411,19 @@ const deserializeAws_queryUpdateConfigurationSetReputationMetricsEnabledCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": throw await deserializeAws_queryConfigurationSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4390,18 +4452,19 @@ const deserializeAws_queryUpdateConfigurationSetSendingEnabledCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": throw await deserializeAws_queryConfigurationSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4436,8 +4499,7 @@ const deserializeAws_queryUpdateConfigurationSetTrackingOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConfigurationSetDoesNotExistException": case "com.amazonaws.ses#ConfigurationSetDoesNotExistException": @@ -4450,10 +4512,12 @@ const deserializeAws_queryUpdateConfigurationSetTrackingOptionsCommandError = as throw await deserializeAws_queryTrackingOptionsDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4482,8 +4546,7 @@ const deserializeAws_queryUpdateCustomVerificationEmailTemplateCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomVerificationEmailInvalidContentException": case "com.amazonaws.ses#CustomVerificationEmailInvalidContentException": @@ -4499,10 +4562,12 @@ const deserializeAws_queryUpdateCustomVerificationEmailTemplateCommandError = as throw await deserializeAws_queryFromEmailAddressNotVerifiedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4534,8 +4599,7 @@ const deserializeAws_queryUpdateReceiptRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidLambdaFunctionException": case "com.amazonaws.ses#InvalidLambdaFunctionException": @@ -4557,10 +4621,12 @@ const deserializeAws_queryUpdateReceiptRuleCommandError = async ( throw await deserializeAws_queryRuleSetDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4592,8 +4658,7 @@ const deserializeAws_queryUpdateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidTemplateException": case "com.amazonaws.ses#InvalidTemplateException": @@ -4603,10 +4668,12 @@ const deserializeAws_queryUpdateTemplateCommandError = async ( throw await deserializeAws_queryTemplateDoesNotExistExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4638,15 +4705,16 @@ const deserializeAws_queryVerifyDomainDkimCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4678,15 +4746,16 @@ const deserializeAws_queryVerifyDomainIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4715,15 +4784,16 @@ const deserializeAws_queryVerifyEmailAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4755,15 +4825,16 @@ const deserializeAws_queryVerifyEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -9312,12 +9383,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-sesv2/src/protocols/Aws_restJson1.ts b/clients/client-sesv2/src/protocols/Aws_restJson1.ts index b656979d3de98..4b3bc5b487562 100644 --- a/clients/client-sesv2/src/protocols/Aws_restJson1.ts +++ b/clients/client-sesv2/src/protocols/Aws_restJson1.ts @@ -3043,8 +3043,7 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3066,10 +3065,12 @@ const deserializeAws_restJson1CreateConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3098,8 +3099,7 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3118,10 +3118,12 @@ const deserializeAws_restJson1CreateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3150,8 +3152,7 @@ const deserializeAws_restJson1CreateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3167,10 +3168,12 @@ const deserializeAws_restJson1CreateContactCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3199,8 +3202,7 @@ const deserializeAws_restJson1CreateContactListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3216,10 +3218,12 @@ const deserializeAws_restJson1CreateContactListCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3248,8 +3252,7 @@ const deserializeAws_restJson1CreateCustomVerificationEmailTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3268,10 +3271,12 @@ const deserializeAws_restJson1CreateCustomVerificationEmailTemplateCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3300,8 +3305,7 @@ const deserializeAws_restJson1CreateDedicatedIpPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3320,10 +3324,12 @@ const deserializeAws_restJson1CreateDedicatedIpPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3360,8 +3366,7 @@ const deserializeAws_restJson1CreateDeliverabilityTestReportCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSuspendedException": case "com.amazonaws.sesv2#AccountSuspendedException": @@ -3392,10 +3397,12 @@ const deserializeAws_restJson1CreateDeliverabilityTestReportCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3436,8 +3443,7 @@ const deserializeAws_restJson1CreateEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3459,10 +3465,12 @@ const deserializeAws_restJson1CreateEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3491,8 +3499,7 @@ const deserializeAws_restJson1CreateEmailIdentityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3511,10 +3518,12 @@ const deserializeAws_restJson1CreateEmailIdentityPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3543,8 +3552,7 @@ const deserializeAws_restJson1CreateEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -3560,10 +3568,12 @@ const deserializeAws_restJson1CreateEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3596,8 +3606,7 @@ const deserializeAws_restJson1CreateImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3610,10 +3619,12 @@ const deserializeAws_restJson1CreateImportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3642,8 +3653,7 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3659,10 +3669,12 @@ const deserializeAws_restJson1DeleteConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3691,8 +3703,7 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3705,10 +3716,12 @@ const deserializeAws_restJson1DeleteConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3737,8 +3750,7 @@ const deserializeAws_restJson1DeleteContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3751,10 +3763,12 @@ const deserializeAws_restJson1DeleteContactCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3783,8 +3797,7 @@ const deserializeAws_restJson1DeleteContactListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3800,10 +3813,12 @@ const deserializeAws_restJson1DeleteContactListCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3832,8 +3847,7 @@ const deserializeAws_restJson1DeleteCustomVerificationEmailTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3846,10 +3860,12 @@ const deserializeAws_restJson1DeleteCustomVerificationEmailTemplateCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3878,8 +3894,7 @@ const deserializeAws_restJson1DeleteDedicatedIpPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3895,10 +3910,12 @@ const deserializeAws_restJson1DeleteDedicatedIpPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3927,8 +3944,7 @@ const deserializeAws_restJson1DeleteEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3944,10 +3960,12 @@ const deserializeAws_restJson1DeleteEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3976,8 +3994,7 @@ const deserializeAws_restJson1DeleteEmailIdentityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -3990,10 +4007,12 @@ const deserializeAws_restJson1DeleteEmailIdentityPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4022,8 +4041,7 @@ const deserializeAws_restJson1DeleteEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4036,10 +4054,12 @@ const deserializeAws_restJson1DeleteEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4068,8 +4088,7 @@ const deserializeAws_restJson1DeleteSuppressedDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4082,10 +4101,12 @@ const deserializeAws_restJson1DeleteSuppressedDestinationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4142,8 +4163,7 @@ const deserializeAws_restJson1GetAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4153,10 +4173,12 @@ const deserializeAws_restJson1GetAccountCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4189,8 +4211,7 @@ const deserializeAws_restJson1GetBlacklistReportsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4203,10 +4224,12 @@ const deserializeAws_restJson1GetBlacklistReportsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4263,8 +4286,7 @@ const deserializeAws_restJson1GetConfigurationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4277,10 +4299,12 @@ const deserializeAws_restJson1GetConfigurationSetCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4313,8 +4337,7 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4327,10 +4350,12 @@ const deserializeAws_restJson1GetConfigurationSetEventDestinationsCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4394,8 +4419,7 @@ const deserializeAws_restJson1GetContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4408,10 +4432,12 @@ const deserializeAws_restJson1GetContactCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4464,8 +4490,7 @@ const deserializeAws_restJson1GetContactListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4478,10 +4503,12 @@ const deserializeAws_restJson1GetContactListCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4534,8 +4561,7 @@ const deserializeAws_restJson1GetCustomVerificationEmailTemplateCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4548,10 +4574,12 @@ const deserializeAws_restJson1GetCustomVerificationEmailTemplateCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4584,8 +4612,7 @@ const deserializeAws_restJson1GetDedicatedIpCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4598,10 +4625,12 @@ const deserializeAws_restJson1GetDedicatedIpCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4638,8 +4667,7 @@ const deserializeAws_restJson1GetDedicatedIpsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4652,10 +4680,12 @@ const deserializeAws_restJson1GetDedicatedIpsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4712,8 +4742,7 @@ const deserializeAws_restJson1GetDeliverabilityDashboardOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4726,10 +4755,12 @@ const deserializeAws_restJson1GetDeliverabilityDashboardOptionsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4781,8 +4812,7 @@ const deserializeAws_restJson1GetDeliverabilityTestReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4795,10 +4825,12 @@ const deserializeAws_restJson1GetDeliverabilityTestReportCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4834,8 +4866,7 @@ const deserializeAws_restJson1GetDomainDeliverabilityCampaignCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4848,10 +4879,12 @@ const deserializeAws_restJson1GetDomainDeliverabilityCampaignCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4888,8 +4921,7 @@ const deserializeAws_restJson1GetDomainStatisticsReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4902,10 +4934,12 @@ const deserializeAws_restJson1GetDomainStatisticsReportCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4966,8 +5000,7 @@ const deserializeAws_restJson1GetEmailIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -4980,10 +5013,12 @@ const deserializeAws_restJson1GetEmailIdentityCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5016,8 +5051,7 @@ const deserializeAws_restJson1GetEmailIdentityPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5030,10 +5064,12 @@ const deserializeAws_restJson1GetEmailIdentityPoliciesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5070,8 +5106,7 @@ const deserializeAws_restJson1GetEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5084,10 +5119,12 @@ const deserializeAws_restJson1GetEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5152,8 +5189,7 @@ const deserializeAws_restJson1GetImportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5166,10 +5202,12 @@ const deserializeAws_restJson1GetImportJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5202,8 +5240,7 @@ const deserializeAws_restJson1GetSuppressedDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5216,10 +5253,12 @@ const deserializeAws_restJson1GetSuppressedDestinationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5256,8 +5295,7 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5267,10 +5305,12 @@ const deserializeAws_restJson1ListConfigurationSetsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5307,8 +5347,7 @@ const deserializeAws_restJson1ListContactListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5318,10 +5357,12 @@ const deserializeAws_restJson1ListContactListsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5358,8 +5399,7 @@ const deserializeAws_restJson1ListContactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5372,10 +5412,12 @@ const deserializeAws_restJson1ListContactsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5415,8 +5457,7 @@ const deserializeAws_restJson1ListCustomVerificationEmailTemplatesCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5426,10 +5467,12 @@ const deserializeAws_restJson1ListCustomVerificationEmailTemplatesCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5466,8 +5509,7 @@ const deserializeAws_restJson1ListDedicatedIpPoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5477,10 +5519,12 @@ const deserializeAws_restJson1ListDedicatedIpPoolsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5520,8 +5564,7 @@ const deserializeAws_restJson1ListDeliverabilityTestReportsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5534,10 +5577,12 @@ const deserializeAws_restJson1ListDeliverabilityTestReportsCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5577,8 +5622,7 @@ const deserializeAws_restJson1ListDomainDeliverabilityCampaignsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5591,10 +5635,12 @@ const deserializeAws_restJson1ListDomainDeliverabilityCampaignsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5631,8 +5677,7 @@ const deserializeAws_restJson1ListEmailIdentitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5642,10 +5687,12 @@ const deserializeAws_restJson1ListEmailIdentitiesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5682,8 +5729,7 @@ const deserializeAws_restJson1ListEmailTemplatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5693,10 +5739,12 @@ const deserializeAws_restJson1ListEmailTemplatesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5733,8 +5781,7 @@ const deserializeAws_restJson1ListImportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5744,10 +5791,12 @@ const deserializeAws_restJson1ListImportJobsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5787,8 +5836,7 @@ const deserializeAws_restJson1ListSuppressedDestinationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5801,10 +5849,12 @@ const deserializeAws_restJson1ListSuppressedDestinationsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5837,8 +5887,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5851,10 +5900,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5883,8 +5934,7 @@ const deserializeAws_restJson1PutAccountDedicatedIpWarmupAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5894,10 +5944,12 @@ const deserializeAws_restJson1PutAccountDedicatedIpWarmupAttributesCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5926,8 +5978,7 @@ const deserializeAws_restJson1PutAccountDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5940,10 +5991,12 @@ const deserializeAws_restJson1PutAccountDetailsCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5972,8 +6025,7 @@ const deserializeAws_restJson1PutAccountSendingAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -5983,10 +6035,12 @@ const deserializeAws_restJson1PutAccountSendingAttributesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6015,8 +6069,7 @@ const deserializeAws_restJson1PutAccountSuppressionAttributesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6026,10 +6079,12 @@ const deserializeAws_restJson1PutAccountSuppressionAttributesCommandError = asyn throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6058,8 +6113,7 @@ const deserializeAws_restJson1PutConfigurationSetDeliveryOptionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6072,10 +6126,12 @@ const deserializeAws_restJson1PutConfigurationSetDeliveryOptionsCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6104,8 +6160,7 @@ const deserializeAws_restJson1PutConfigurationSetReputationOptionsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6118,10 +6173,12 @@ const deserializeAws_restJson1PutConfigurationSetReputationOptionsCommandError = throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6150,8 +6207,7 @@ const deserializeAws_restJson1PutConfigurationSetSendingOptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6164,10 +6220,12 @@ const deserializeAws_restJson1PutConfigurationSetSendingOptionsCommandError = as throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6196,8 +6254,7 @@ const deserializeAws_restJson1PutConfigurationSetSuppressionOptionsCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6210,10 +6267,12 @@ const deserializeAws_restJson1PutConfigurationSetSuppressionOptionsCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6242,8 +6301,7 @@ const deserializeAws_restJson1PutConfigurationSetTrackingOptionsCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6256,10 +6314,12 @@ const deserializeAws_restJson1PutConfigurationSetTrackingOptionsCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6288,8 +6348,7 @@ const deserializeAws_restJson1PutDedicatedIpInPoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6302,10 +6361,12 @@ const deserializeAws_restJson1PutDedicatedIpInPoolCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6334,8 +6395,7 @@ const deserializeAws_restJson1PutDedicatedIpWarmupAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6348,10 +6408,12 @@ const deserializeAws_restJson1PutDedicatedIpWarmupAttributesCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6380,8 +6442,7 @@ const deserializeAws_restJson1PutDeliverabilityDashboardOptionCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.sesv2#AlreadyExistsException": @@ -6400,10 +6461,12 @@ const deserializeAws_restJson1PutDeliverabilityDashboardOptionCommandError = asy throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6432,8 +6495,7 @@ const deserializeAws_restJson1PutEmailIdentityConfigurationSetAttributesCommandE body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6446,10 +6508,12 @@ const deserializeAws_restJson1PutEmailIdentityConfigurationSetAttributesCommandE throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6478,8 +6542,7 @@ const deserializeAws_restJson1PutEmailIdentityDkimAttributesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6492,10 +6555,12 @@ const deserializeAws_restJson1PutEmailIdentityDkimAttributesCommandError = async throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6532,8 +6597,7 @@ const deserializeAws_restJson1PutEmailIdentityDkimSigningAttributesCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6546,10 +6610,12 @@ const deserializeAws_restJson1PutEmailIdentityDkimSigningAttributesCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6578,8 +6644,7 @@ const deserializeAws_restJson1PutEmailIdentityFeedbackAttributesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6592,10 +6657,12 @@ const deserializeAws_restJson1PutEmailIdentityFeedbackAttributesCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6624,8 +6691,7 @@ const deserializeAws_restJson1PutEmailIdentityMailFromAttributesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6638,10 +6704,12 @@ const deserializeAws_restJson1PutEmailIdentityMailFromAttributesCommandError = a throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6670,8 +6738,7 @@ const deserializeAws_restJson1PutSuppressedDestinationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6681,10 +6748,12 @@ const deserializeAws_restJson1PutSuppressedDestinationCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6720,8 +6789,7 @@ const deserializeAws_restJson1SendBulkEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSuspendedException": case "com.amazonaws.sesv2#AccountSuspendedException": @@ -6749,10 +6817,12 @@ const deserializeAws_restJson1SendBulkEmailCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6785,8 +6855,7 @@ const deserializeAws_restJson1SendCustomVerificationEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6811,10 +6880,12 @@ const deserializeAws_restJson1SendCustomVerificationEmailCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6847,8 +6918,7 @@ const deserializeAws_restJson1SendEmailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccountSuspendedException": case "com.amazonaws.sesv2#AccountSuspendedException": @@ -6876,10 +6946,12 @@ const deserializeAws_restJson1SendEmailCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6908,8 +6980,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6925,10 +6996,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6961,8 +7034,7 @@ const deserializeAws_restJson1TestRenderEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -6975,10 +7047,12 @@ const deserializeAws_restJson1TestRenderEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7007,8 +7081,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7024,10 +7097,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7056,8 +7131,7 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7070,10 +7144,12 @@ const deserializeAws_restJson1UpdateConfigurationSetEventDestinationCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7102,8 +7178,7 @@ const deserializeAws_restJson1UpdateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7119,10 +7194,12 @@ const deserializeAws_restJson1UpdateContactCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7151,8 +7228,7 @@ const deserializeAws_restJson1UpdateContactListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7168,10 +7244,12 @@ const deserializeAws_restJson1UpdateContactListCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7200,8 +7278,7 @@ const deserializeAws_restJson1UpdateCustomVerificationEmailTemplateCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7214,10 +7291,12 @@ const deserializeAws_restJson1UpdateCustomVerificationEmailTemplateCommandError throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7246,8 +7325,7 @@ const deserializeAws_restJson1UpdateEmailIdentityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7260,10 +7338,12 @@ const deserializeAws_restJson1UpdateEmailIdentityPolicyCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7292,8 +7372,7 @@ const deserializeAws_restJson1UpdateEmailTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.sesv2#BadRequestException": @@ -7306,10 +7385,12 @@ const deserializeAws_restJson1UpdateEmailTemplateCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9021,7 +9102,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9047,6 +9128,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sfn/src/protocols/Aws_json1_0.ts b/clients/client-sfn/src/protocols/Aws_json1_0.ts index f43e5fc8bbd4d..4a6823220adc1 100644 --- a/clients/client-sfn/src/protocols/Aws_json1_0.ts +++ b/clients/client-sfn/src/protocols/Aws_json1_0.ts @@ -503,8 +503,7 @@ const deserializeAws_json1_0CreateActivityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActivityLimitExceeded": case "com.amazonaws.sfn#ActivityLimitExceeded": @@ -517,10 +516,12 @@ const deserializeAws_json1_0CreateActivityCommandError = async ( throw await deserializeAws_json1_0TooManyTagsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -552,8 +553,7 @@ const deserializeAws_json1_0CreateStateMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -587,10 +587,12 @@ const deserializeAws_json1_0CreateStateMachineCommandError = async ( throw await deserializeAws_json1_0TooManyTagsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -622,18 +624,19 @@ const deserializeAws_json1_0DeleteActivityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -665,18 +668,19 @@ const deserializeAws_json1_0DeleteStateMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -708,8 +712,7 @@ const deserializeAws_json1_0DescribeActivityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActivityDoesNotExist": case "com.amazonaws.sfn#ActivityDoesNotExist": @@ -719,10 +722,12 @@ const deserializeAws_json1_0DescribeActivityCommandError = async ( throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -754,8 +759,7 @@ const deserializeAws_json1_0DescribeExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExecutionDoesNotExist": case "com.amazonaws.sfn#ExecutionDoesNotExist": @@ -765,10 +769,12 @@ const deserializeAws_json1_0DescribeExecutionCommandError = async ( throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -800,8 +806,7 @@ const deserializeAws_json1_0DescribeStateMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -811,10 +816,12 @@ const deserializeAws_json1_0DescribeStateMachineCommandError = async ( throw await deserializeAws_json1_0StateMachineDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -846,8 +853,7 @@ const deserializeAws_json1_0DescribeStateMachineForExecutionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExecutionDoesNotExist": case "com.amazonaws.sfn#ExecutionDoesNotExist": @@ -857,10 +863,12 @@ const deserializeAws_json1_0DescribeStateMachineForExecutionCommandError = async throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -892,8 +900,7 @@ const deserializeAws_json1_0GetActivityTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ActivityDoesNotExist": case "com.amazonaws.sfn#ActivityDoesNotExist": @@ -906,10 +913,12 @@ const deserializeAws_json1_0GetActivityTaskCommandError = async ( throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -941,8 +950,7 @@ const deserializeAws_json1_0GetExecutionHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExecutionDoesNotExist": case "com.amazonaws.sfn#ExecutionDoesNotExist": @@ -955,10 +963,12 @@ const deserializeAws_json1_0GetExecutionHistoryCommandError = async ( throw await deserializeAws_json1_0InvalidTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -990,18 +1000,19 @@ const deserializeAws_json1_0ListActivitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidToken": case "com.amazonaws.sfn#InvalidToken": throw await deserializeAws_json1_0InvalidTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1033,8 +1044,7 @@ const deserializeAws_json1_0ListExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1050,10 +1060,12 @@ const deserializeAws_json1_0ListExecutionsCommandError = async ( throw await deserializeAws_json1_0StateMachineTypeNotSupportedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1085,18 +1097,19 @@ const deserializeAws_json1_0ListStateMachinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidToken": case "com.amazonaws.sfn#InvalidToken": throw await deserializeAws_json1_0InvalidTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1128,8 +1141,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1139,10 +1151,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1174,8 +1188,7 @@ const deserializeAws_json1_0SendTaskFailureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidToken": case "com.amazonaws.sfn#InvalidToken": @@ -1188,10 +1201,12 @@ const deserializeAws_json1_0SendTaskFailureCommandError = async ( throw await deserializeAws_json1_0TaskTimedOutResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1223,8 +1238,7 @@ const deserializeAws_json1_0SendTaskHeartbeatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidToken": case "com.amazonaws.sfn#InvalidToken": @@ -1237,10 +1251,12 @@ const deserializeAws_json1_0SendTaskHeartbeatCommandError = async ( throw await deserializeAws_json1_0TaskTimedOutResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1272,8 +1288,7 @@ const deserializeAws_json1_0SendTaskSuccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidOutput": case "com.amazonaws.sfn#InvalidOutput": @@ -1289,10 +1304,12 @@ const deserializeAws_json1_0SendTaskSuccessCommandError = async ( throw await deserializeAws_json1_0TaskTimedOutResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1324,8 +1341,7 @@ const deserializeAws_json1_0StartExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExecutionAlreadyExists": case "com.amazonaws.sfn#ExecutionAlreadyExists": @@ -1350,10 +1366,12 @@ const deserializeAws_json1_0StartExecutionCommandError = async ( throw await deserializeAws_json1_0StateMachineDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1385,8 +1403,7 @@ const deserializeAws_json1_0StartSyncExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1408,10 +1425,12 @@ const deserializeAws_json1_0StartSyncExecutionCommandError = async ( throw await deserializeAws_json1_0StateMachineTypeNotSupportedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1443,8 +1462,7 @@ const deserializeAws_json1_0StopExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExecutionDoesNotExist": case "com.amazonaws.sfn#ExecutionDoesNotExist": @@ -1454,10 +1472,12 @@ const deserializeAws_json1_0StopExecutionCommandError = async ( throw await deserializeAws_json1_0InvalidArnResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1489,8 +1509,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1503,10 +1522,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0TooManyTagsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1538,8 +1559,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1549,10 +1569,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ResourceNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1584,8 +1606,7 @@ const deserializeAws_json1_0UpdateStateMachineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidArn": case "com.amazonaws.sfn#InvalidArn": @@ -1610,10 +1631,12 @@ const deserializeAws_json1_0UpdateStateMachineCommandError = async ( throw await deserializeAws_json1_0StateMachineDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3378,7 +3401,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3404,6 +3427,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-shield/src/protocols/Aws_json1_1.ts b/clients/client-shield/src/protocols/Aws_json1_1.ts index 13ad24c46bf78..b96be4fed5c38 100644 --- a/clients/client-shield/src/protocols/Aws_json1_1.ts +++ b/clients/client-shield/src/protocols/Aws_json1_1.ts @@ -734,8 +734,7 @@ const deserializeAws_json1_1AssociateDRTLogBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedForDependencyException": case "com.amazonaws.shield#AccessDeniedForDependencyException": @@ -763,10 +762,12 @@ const deserializeAws_json1_1AssociateDRTLogBucketCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -798,8 +799,7 @@ const deserializeAws_json1_1AssociateDRTRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedForDependencyException": case "com.amazonaws.shield#AccessDeniedForDependencyException": @@ -821,10 +821,12 @@ const deserializeAws_json1_1AssociateDRTRoleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -856,8 +858,7 @@ const deserializeAws_json1_1AssociateHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -879,10 +880,12 @@ const deserializeAws_json1_1AssociateHealthCheckCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -914,8 +917,7 @@ const deserializeAws_json1_1AssociateProactiveEngagementDetailsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -934,10 +936,12 @@ const deserializeAws_json1_1AssociateProactiveEngagementDetailsCommandError = as throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -969,8 +973,7 @@ const deserializeAws_json1_1CreateProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -998,10 +1001,12 @@ const deserializeAws_json1_1CreateProtectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1033,8 +1038,7 @@ const deserializeAws_json1_1CreateProtectionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1056,10 +1060,12 @@ const deserializeAws_json1_1CreateProtectionGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1091,8 +1097,7 @@ const deserializeAws_json1_1CreateSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1102,10 +1107,12 @@ const deserializeAws_json1_1CreateSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1137,8 +1144,7 @@ const deserializeAws_json1_1DeleteProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1151,10 +1157,12 @@ const deserializeAws_json1_1DeleteProtectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1186,8 +1194,7 @@ const deserializeAws_json1_1DeleteProtectionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1200,10 +1207,12 @@ const deserializeAws_json1_1DeleteProtectionGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1235,8 +1244,7 @@ const deserializeAws_json1_1DeleteSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1249,10 +1257,12 @@ const deserializeAws_json1_1DeleteSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1284,8 +1294,7 @@ const deserializeAws_json1_1DescribeAttackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.shield#AccessDeniedException": @@ -1295,10 +1304,12 @@ const deserializeAws_json1_1DescribeAttackCommandError = async ( throw await deserializeAws_json1_1InternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1330,18 +1341,19 @@ const deserializeAws_json1_1DescribeAttackStatisticsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": throw await deserializeAws_json1_1InternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1373,8 +1385,7 @@ const deserializeAws_json1_1DescribeDRTAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1384,10 +1395,12 @@ const deserializeAws_json1_1DescribeDRTAccessCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1419,8 +1432,7 @@ const deserializeAws_json1_1DescribeEmergencyContactSettingsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1430,10 +1442,12 @@ const deserializeAws_json1_1DescribeEmergencyContactSettingsCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1465,8 +1479,7 @@ const deserializeAws_json1_1DescribeProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1479,10 +1492,12 @@ const deserializeAws_json1_1DescribeProtectionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1514,8 +1529,7 @@ const deserializeAws_json1_1DescribeProtectionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1525,10 +1539,12 @@ const deserializeAws_json1_1DescribeProtectionGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1560,8 +1576,7 @@ const deserializeAws_json1_1DescribeSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1571,10 +1586,12 @@ const deserializeAws_json1_1DescribeSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1606,8 +1623,7 @@ const deserializeAws_json1_1DisableApplicationLayerAutomaticResponseCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1626,10 +1642,12 @@ const deserializeAws_json1_1DisableApplicationLayerAutomaticResponseCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1661,8 +1679,7 @@ const deserializeAws_json1_1DisableProactiveEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1681,10 +1698,12 @@ const deserializeAws_json1_1DisableProactiveEngagementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1716,8 +1735,7 @@ const deserializeAws_json1_1DisassociateDRTLogBucketCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedForDependencyException": case "com.amazonaws.shield#AccessDeniedForDependencyException": @@ -1739,10 +1757,12 @@ const deserializeAws_json1_1DisassociateDRTLogBucketCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1774,8 +1794,7 @@ const deserializeAws_json1_1DisassociateDRTRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1791,10 +1810,12 @@ const deserializeAws_json1_1DisassociateDRTRoleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1826,8 +1847,7 @@ const deserializeAws_json1_1DisassociateHealthCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1846,10 +1866,12 @@ const deserializeAws_json1_1DisassociateHealthCheckCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1881,8 +1903,7 @@ const deserializeAws_json1_1EnableApplicationLayerAutomaticResponseCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1904,10 +1925,12 @@ const deserializeAws_json1_1EnableApplicationLayerAutomaticResponseCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1939,8 +1962,7 @@ const deserializeAws_json1_1EnableProactiveEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -1959,10 +1981,12 @@ const deserializeAws_json1_1EnableProactiveEngagementCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1994,18 +2018,19 @@ const deserializeAws_json1_1GetSubscriptionStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": throw await deserializeAws_json1_1InternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2037,8 +2062,7 @@ const deserializeAws_json1_1ListAttacksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2051,10 +2075,12 @@ const deserializeAws_json1_1ListAttacksCommandError = async ( throw await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2086,8 +2112,7 @@ const deserializeAws_json1_1ListProtectionGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2100,10 +2125,12 @@ const deserializeAws_json1_1ListProtectionGroupsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2135,8 +2162,7 @@ const deserializeAws_json1_1ListProtectionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2149,10 +2175,12 @@ const deserializeAws_json1_1ListProtectionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2184,8 +2212,7 @@ const deserializeAws_json1_1ListResourcesInProtectionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2198,10 +2225,12 @@ const deserializeAws_json1_1ListResourcesInProtectionGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2233,8 +2262,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2247,10 +2275,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2282,8 +2312,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2299,10 +2328,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2334,8 +2365,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2351,10 +2381,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2418,7 @@ const deserializeAws_json1_1UpdateApplicationLayerAutomaticResponseCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2406,10 +2437,12 @@ const deserializeAws_json1_1UpdateApplicationLayerAutomaticResponseCommandError throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2441,8 +2474,7 @@ const deserializeAws_json1_1UpdateEmergencyContactSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2458,10 +2490,12 @@ const deserializeAws_json1_1UpdateEmergencyContactSettingsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2493,8 +2527,7 @@ const deserializeAws_json1_1UpdateProtectionGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2510,10 +2543,12 @@ const deserializeAws_json1_1UpdateProtectionGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2545,8 +2580,7 @@ const deserializeAws_json1_1UpdateSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalErrorException": case "com.amazonaws.shield#InternalErrorException": @@ -2565,10 +2599,12 @@ const deserializeAws_json1_1UpdateSubscriptionCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4245,7 +4281,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4271,6 +4307,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-signer/src/protocols/Aws_restJson1.ts b/clients/client-signer/src/protocols/Aws_restJson1.ts index ffdbab7045977..b214f4a78151c 100644 --- a/clients/client-signer/src/protocols/Aws_restJson1.ts +++ b/clients/client-signer/src/protocols/Aws_restJson1.ts @@ -695,8 +695,7 @@ const deserializeAws_restJson1AddProfilePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -721,10 +720,12 @@ const deserializeAws_restJson1AddProfilePermissionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -753,8 +754,7 @@ const deserializeAws_restJson1CancelSigningProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -770,10 +770,12 @@ const deserializeAws_restJson1CancelSigningProfileCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -878,8 +880,7 @@ const deserializeAws_restJson1DescribeSigningJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -895,10 +896,12 @@ const deserializeAws_restJson1DescribeSigningJobCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -963,8 +966,7 @@ const deserializeAws_restJson1GetSigningPlatformCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -980,10 +982,12 @@ const deserializeAws_restJson1GetSigningPlatformCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1071,8 +1075,7 @@ const deserializeAws_restJson1GetSigningProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1088,10 +1091,12 @@ const deserializeAws_restJson1GetSigningProfileCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1136,8 +1141,7 @@ const deserializeAws_restJson1ListProfilePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1156,10 +1160,12 @@ const deserializeAws_restJson1ListProfilePermissionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1196,8 +1202,7 @@ const deserializeAws_restJson1ListSigningJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1213,10 +1218,12 @@ const deserializeAws_restJson1ListSigningJobsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1253,8 +1260,7 @@ const deserializeAws_restJson1ListSigningPlatformsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1270,10 +1276,12 @@ const deserializeAws_restJson1ListSigningPlatformsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1310,8 +1318,7 @@ const deserializeAws_restJson1ListSigningProfilesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1324,10 +1331,12 @@ const deserializeAws_restJson1ListSigningProfilesCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1360,8 +1369,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.signer#BadRequestException": @@ -1377,10 +1385,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1421,8 +1431,7 @@ const deserializeAws_restJson1PutSigningProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1441,10 +1450,12 @@ const deserializeAws_restJson1PutSigningProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1477,8 +1488,7 @@ const deserializeAws_restJson1RemoveProfilePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1500,10 +1510,12 @@ const deserializeAws_restJson1RemoveProfilePermissionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1532,8 +1544,7 @@ const deserializeAws_restJson1RevokeSignatureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1552,10 +1563,12 @@ const deserializeAws_restJson1RevokeSignatureCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1584,8 +1597,7 @@ const deserializeAws_restJson1RevokeSigningProfileCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1604,10 +1616,12 @@ const deserializeAws_restJson1RevokeSigningProfileCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1644,8 +1658,7 @@ const deserializeAws_restJson1StartSigningJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.signer#AccessDeniedException": @@ -1667,10 +1680,12 @@ const deserializeAws_restJson1StartSigningJobCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1699,8 +1714,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.signer#BadRequestException": @@ -1716,10 +1730,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1748,8 +1764,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.signer#BadRequestException": @@ -1765,10 +1780,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2443,7 +2460,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2469,6 +2486,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sms/src/protocols/Aws_json1_1.ts b/clients/client-sms/src/protocols/Aws_json1_1.ts index 803aa391c0019..5aaa375ae0f92 100644 --- a/clients/client-sms/src/protocols/Aws_json1_1.ts +++ b/clients/client-sms/src/protocols/Aws_json1_1.ts @@ -708,8 +708,7 @@ const deserializeAws_json1_1CreateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -728,10 +727,12 @@ const deserializeAws_json1_1CreateAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -763,8 +764,7 @@ const deserializeAws_json1_1CreateReplicationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -795,10 +795,12 @@ const deserializeAws_json1_1CreateReplicationJobCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -830,8 +832,7 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -850,10 +851,12 @@ const deserializeAws_json1_1DeleteAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -885,8 +888,7 @@ const deserializeAws_json1_1DeleteAppLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -905,10 +907,12 @@ const deserializeAws_json1_1DeleteAppLaunchConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -940,8 +944,7 @@ const deserializeAws_json1_1DeleteAppReplicationConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -960,10 +963,12 @@ const deserializeAws_json1_1DeleteAppReplicationConfigurationCommandError = asyn throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -995,8 +1000,7 @@ const deserializeAws_json1_1DeleteAppValidationConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1015,10 +1019,12 @@ const deserializeAws_json1_1DeleteAppValidationConfigurationCommandError = async throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1050,8 +1056,7 @@ const deserializeAws_json1_1DeleteReplicationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1070,10 +1075,12 @@ const deserializeAws_json1_1DeleteReplicationJobCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1105,8 +1112,7 @@ const deserializeAws_json1_1DeleteServerCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1122,10 +1128,12 @@ const deserializeAws_json1_1DeleteServerCatalogCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1157,8 +1165,7 @@ const deserializeAws_json1_1DisassociateConnectorCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1174,10 +1181,12 @@ const deserializeAws_json1_1DisassociateConnectorCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1218,7 @@ const deserializeAws_json1_1GenerateChangeSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1229,10 +1237,12 @@ const deserializeAws_json1_1GenerateChangeSetCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1264,8 +1274,7 @@ const deserializeAws_json1_1GenerateTemplateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1284,10 +1293,12 @@ const deserializeAws_json1_1GenerateTemplateCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1319,8 +1330,7 @@ const deserializeAws_json1_1GetAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1339,10 +1349,12 @@ const deserializeAws_json1_1GetAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1374,8 +1386,7 @@ const deserializeAws_json1_1GetAppLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1394,10 +1405,12 @@ const deserializeAws_json1_1GetAppLaunchConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1429,8 +1442,7 @@ const deserializeAws_json1_1GetAppReplicationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1449,10 +1461,12 @@ const deserializeAws_json1_1GetAppReplicationConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1484,8 +1498,7 @@ const deserializeAws_json1_1GetAppValidationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1504,10 +1517,12 @@ const deserializeAws_json1_1GetAppValidationConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1539,8 +1554,7 @@ const deserializeAws_json1_1GetAppValidationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1559,10 +1573,12 @@ const deserializeAws_json1_1GetAppValidationOutputCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1594,18 +1610,19 @@ const deserializeAws_json1_1GetConnectorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "UnauthorizedOperationException": case "com.amazonaws.sms#UnauthorizedOperationException": throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1637,8 +1654,7 @@ const deserializeAws_json1_1GetReplicationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1651,10 +1667,12 @@ const deserializeAws_json1_1GetReplicationJobsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1686,8 +1704,7 @@ const deserializeAws_json1_1GetReplicationRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1700,10 +1717,12 @@ const deserializeAws_json1_1GetReplicationRunsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1735,8 +1754,7 @@ const deserializeAws_json1_1GetServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1752,10 +1770,12 @@ const deserializeAws_json1_1GetServersCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1787,8 +1807,7 @@ const deserializeAws_json1_1ImportAppCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1807,10 +1826,12 @@ const deserializeAws_json1_1ImportAppCatalogCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1842,8 +1863,7 @@ const deserializeAws_json1_1ImportServerCatalogCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.sms#InvalidParameterException": @@ -1862,10 +1882,12 @@ const deserializeAws_json1_1ImportServerCatalogCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1897,8 +1919,7 @@ const deserializeAws_json1_1LaunchAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1917,10 +1938,12 @@ const deserializeAws_json1_1LaunchAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1952,8 +1975,7 @@ const deserializeAws_json1_1ListAppsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -1972,10 +1994,12 @@ const deserializeAws_json1_1ListAppsCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2007,8 +2031,7 @@ const deserializeAws_json1_1NotifyAppValidationOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2027,10 +2050,12 @@ const deserializeAws_json1_1NotifyAppValidationOutputCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2062,8 +2087,7 @@ const deserializeAws_json1_1PutAppLaunchConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2082,10 +2106,12 @@ const deserializeAws_json1_1PutAppLaunchConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2117,8 +2143,7 @@ const deserializeAws_json1_1PutAppReplicationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2137,10 +2162,12 @@ const deserializeAws_json1_1PutAppReplicationConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2172,8 +2199,7 @@ const deserializeAws_json1_1PutAppValidationConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2192,10 +2218,12 @@ const deserializeAws_json1_1PutAppValidationConfigurationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2227,8 +2255,7 @@ const deserializeAws_json1_1StartAppReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2247,10 +2274,12 @@ const deserializeAws_json1_1StartAppReplicationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2282,8 +2311,7 @@ const deserializeAws_json1_1StartOnDemandAppReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2302,10 +2330,12 @@ const deserializeAws_json1_1StartOnDemandAppReplicationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2337,8 +2367,7 @@ const deserializeAws_json1_1StartOnDemandReplicationRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DryRunOperationException": case "com.amazonaws.sms#DryRunOperationException": @@ -2360,10 +2389,12 @@ const deserializeAws_json1_1StartOnDemandReplicationRunCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2395,8 +2426,7 @@ const deserializeAws_json1_1StopAppReplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2415,10 +2445,12 @@ const deserializeAws_json1_1StopAppReplicationCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2450,8 +2482,7 @@ const deserializeAws_json1_1TerminateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2470,10 +2501,12 @@ const deserializeAws_json1_1TerminateAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2505,8 +2538,7 @@ const deserializeAws_json1_1UpdateAppCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2525,10 +2557,12 @@ const deserializeAws_json1_1UpdateAppCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2560,8 +2594,7 @@ const deserializeAws_json1_1UpdateReplicationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalError": case "com.amazonaws.sms#InternalError": @@ -2589,10 +2622,12 @@ const deserializeAws_json1_1UpdateReplicationJobCommandError = async ( throw await deserializeAws_json1_1UnauthorizedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4670,7 +4705,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4696,6 +4731,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-snow-device-management/src/protocols/Aws_restJson1.ts b/clients/client-snow-device-management/src/protocols/Aws_restJson1.ts index 0024b11083bd8..72a1b663d7de3 100644 --- a/clients/client-snow-device-management/src/protocols/Aws_restJson1.ts +++ b/clients/client-snow-device-management/src/protocols/Aws_restJson1.ts @@ -491,8 +491,7 @@ const deserializeAws_restJson1CancelTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -511,10 +510,12 @@ const deserializeAws_restJson1CancelTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -551,8 +552,7 @@ const deserializeAws_restJson1CreateTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -574,10 +574,12 @@ const deserializeAws_restJson1CreateTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -653,8 +655,7 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -673,10 +674,12 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -709,8 +712,7 @@ const deserializeAws_restJson1DescribeDeviceEc2InstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -729,10 +731,12 @@ const deserializeAws_restJson1DescribeDeviceEc2InstancesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -785,8 +789,7 @@ const deserializeAws_restJson1DescribeExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -805,10 +808,12 @@ const deserializeAws_restJson1DescribeExecutionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -873,8 +878,7 @@ const deserializeAws_restJson1DescribeTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -893,10 +897,12 @@ const deserializeAws_restJson1DescribeTaskCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -933,8 +939,7 @@ const deserializeAws_restJson1ListDeviceResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -953,10 +958,12 @@ const deserializeAws_restJson1ListDeviceResourcesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -993,8 +1000,7 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -1010,10 +1016,12 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1050,8 +1058,7 @@ const deserializeAws_restJson1ListExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -1070,10 +1077,12 @@ const deserializeAws_restJson1ListExecutionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1106,8 +1115,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.snowdevicemanagement#InternalServerException": @@ -1120,10 +1128,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1170,7 @@ const deserializeAws_restJson1ListTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.snowdevicemanagement#AccessDeniedException": @@ -1177,10 +1186,12 @@ const deserializeAws_restJson1ListTasksCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1220,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.snowdevicemanagement#InternalServerException": @@ -1223,10 +1233,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1255,8 +1267,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.snowdevicemanagement#InternalServerException": @@ -1269,10 +1280,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1777,7 +1790,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1803,6 +1816,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-snowball/src/protocols/Aws_json1_1.ts b/clients/client-snowball/src/protocols/Aws_json1_1.ts index 123a15406f138..0182a396cb852 100644 --- a/clients/client-snowball/src/protocols/Aws_json1_1.ts +++ b/clients/client-snowball/src/protocols/Aws_json1_1.ts @@ -507,8 +507,7 @@ const deserializeAws_json1_1CancelClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -521,10 +520,12 @@ const deserializeAws_json1_1CancelClusterCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -556,8 +557,7 @@ const deserializeAws_json1_1CancelJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -570,10 +570,12 @@ const deserializeAws_json1_1CancelJobCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -605,8 +607,7 @@ const deserializeAws_json1_1CreateAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAddressException": case "com.amazonaws.snowball#InvalidAddressException": @@ -616,10 +617,12 @@ const deserializeAws_json1_1CreateAddressCommandError = async ( throw await deserializeAws_json1_1UnsupportedAddressExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -651,8 +654,7 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "Ec2RequestFailedException": case "com.amazonaws.snowball#Ec2RequestFailedException": @@ -668,10 +670,12 @@ const deserializeAws_json1_1CreateClusterCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -703,8 +707,7 @@ const deserializeAws_json1_1CreateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterLimitExceededException": case "com.amazonaws.snowball#ClusterLimitExceededException": @@ -723,10 +726,12 @@ const deserializeAws_json1_1CreateJobCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -758,18 +763,19 @@ const deserializeAws_json1_1CreateLongTermPricingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceException": case "com.amazonaws.snowball#InvalidResourceException": throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -801,8 +807,7 @@ const deserializeAws_json1_1CreateReturnShippingLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.snowball#ConflictException": @@ -821,10 +826,12 @@ const deserializeAws_json1_1CreateReturnShippingLabelCommandError = async ( throw await deserializeAws_json1_1ReturnShippingLabelAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -856,18 +863,19 @@ const deserializeAws_json1_1DescribeAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceException": case "com.amazonaws.snowball#InvalidResourceException": throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -899,8 +907,7 @@ const deserializeAws_json1_1DescribeAddressesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.snowball#InvalidNextTokenException": @@ -910,10 +917,12 @@ const deserializeAws_json1_1DescribeAddressesCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -945,18 +954,19 @@ const deserializeAws_json1_1DescribeClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceException": case "com.amazonaws.snowball#InvalidResourceException": throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -988,18 +998,19 @@ const deserializeAws_json1_1DescribeJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceException": case "com.amazonaws.snowball#InvalidResourceException": throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1031,8 +1042,7 @@ const deserializeAws_json1_1DescribeReturnShippingLabelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.snowball#ConflictException": @@ -1045,10 +1055,12 @@ const deserializeAws_json1_1DescribeReturnShippingLabelCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1080,8 +1092,7 @@ const deserializeAws_json1_1GetJobManifestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -1091,10 +1102,12 @@ const deserializeAws_json1_1GetJobManifestCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1126,8 +1139,7 @@ const deserializeAws_json1_1GetJobUnlockCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -1137,10 +1149,12 @@ const deserializeAws_json1_1GetJobUnlockCodeCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1172,15 +1186,16 @@ const deserializeAws_json1_1GetSnowballUsageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1212,8 +1227,7 @@ const deserializeAws_json1_1GetSoftwareUpdatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -1223,10 +1237,12 @@ const deserializeAws_json1_1GetSoftwareUpdatesCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1258,8 +1274,7 @@ const deserializeAws_json1_1ListClusterJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.snowball#InvalidNextTokenException": @@ -1269,10 +1284,12 @@ const deserializeAws_json1_1ListClusterJobsCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1304,18 +1321,19 @@ const deserializeAws_json1_1ListClustersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.snowball#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1347,8 +1365,7 @@ const deserializeAws_json1_1ListCompatibleImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "Ec2RequestFailedException": case "com.amazonaws.snowball#Ec2RequestFailedException": @@ -1358,10 +1375,12 @@ const deserializeAws_json1_1ListCompatibleImagesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1393,18 +1412,19 @@ const deserializeAws_json1_1ListJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.snowball#InvalidNextTokenException": throw await deserializeAws_json1_1InvalidNextTokenExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1436,8 +1456,7 @@ const deserializeAws_json1_1ListLongTermPricingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidNextTokenException": case "com.amazonaws.snowball#InvalidNextTokenException": @@ -1447,10 +1466,12 @@ const deserializeAws_json1_1ListLongTermPricingCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1482,8 +1503,7 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "Ec2RequestFailedException": case "com.amazonaws.snowball#Ec2RequestFailedException": @@ -1502,10 +1522,12 @@ const deserializeAws_json1_1UpdateClusterCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1537,8 +1559,7 @@ const deserializeAws_json1_1UpdateJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ClusterLimitExceededException": case "com.amazonaws.snowball#ClusterLimitExceededException": @@ -1560,10 +1581,12 @@ const deserializeAws_json1_1UpdateJobCommandError = async ( throw await deserializeAws_json1_1KMSRequestFailedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1595,8 +1618,7 @@ const deserializeAws_json1_1UpdateJobShipmentStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidJobStateException": case "com.amazonaws.snowball#InvalidJobStateException": @@ -1606,10 +1628,12 @@ const deserializeAws_json1_1UpdateJobShipmentStateCommandError = async ( throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1641,18 +1665,19 @@ const deserializeAws_json1_1UpdateLongTermPricingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidResourceException": case "com.amazonaws.snowball#InvalidResourceException": throw await deserializeAws_json1_1InvalidResourceExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3230,7 +3255,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3256,6 +3281,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sns/src/protocols/Aws_query.ts b/clients/client-sns/src/protocols/Aws_query.ts index cf48ca374e7ad..35f9b2cf785cb 100644 --- a/clients/client-sns/src/protocols/Aws_query.ts +++ b/clients/client-sns/src/protocols/Aws_query.ts @@ -906,8 +906,7 @@ const deserializeAws_queryAddPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -923,10 +922,12 @@ const deserializeAws_queryAddPermissionCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -958,8 +959,7 @@ const deserializeAws_queryCheckIfPhoneNumberIsOptedOutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -975,10 +975,12 @@ const deserializeAws_queryCheckIfPhoneNumberIsOptedOutCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1010,8 +1012,7 @@ const deserializeAws_queryConfirmSubscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1033,10 +1034,12 @@ const deserializeAws_queryConfirmSubscriptionCommandError = async ( throw await deserializeAws_querySubscriptionLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1068,8 +1071,7 @@ const deserializeAws_queryCreatePlatformApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1082,10 +1084,12 @@ const deserializeAws_queryCreatePlatformApplicationCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1117,8 +1121,7 @@ const deserializeAws_queryCreatePlatformEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1134,10 +1137,12 @@ const deserializeAws_queryCreatePlatformEndpointCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1169,8 +1174,7 @@ const deserializeAws_queryCreateSMSSandboxPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1192,10 +1196,12 @@ const deserializeAws_queryCreateSMSSandboxPhoneNumberCommandError = async ( throw await deserializeAws_queryUserErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1227,8 +1233,7 @@ const deserializeAws_queryCreateTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1259,10 +1264,12 @@ const deserializeAws_queryCreateTopicCommandError = async ( throw await deserializeAws_queryTopicLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1291,8 +1298,7 @@ const deserializeAws_queryDeleteEndpointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1305,10 +1311,12 @@ const deserializeAws_queryDeleteEndpointCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1337,8 +1345,7 @@ const deserializeAws_queryDeletePlatformApplicationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1351,10 +1358,12 @@ const deserializeAws_queryDeletePlatformApplicationCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1386,8 +1395,7 @@ const deserializeAws_queryDeleteSMSSandboxPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1409,10 +1417,12 @@ const deserializeAws_queryDeleteSMSSandboxPhoneNumberCommandError = async ( throw await deserializeAws_queryUserErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1441,8 +1451,7 @@ const deserializeAws_queryDeleteTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1467,10 +1476,12 @@ const deserializeAws_queryDeleteTopicCommandError = async ( throw await deserializeAws_queryTagPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1502,8 +1513,7 @@ const deserializeAws_queryGetEndpointAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1519,10 +1529,12 @@ const deserializeAws_queryGetEndpointAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1557,8 +1569,7 @@ const deserializeAws_queryGetPlatformApplicationAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1574,10 +1585,12 @@ const deserializeAws_queryGetPlatformApplicationAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1609,8 +1622,7 @@ const deserializeAws_queryGetSMSAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1626,10 +1638,12 @@ const deserializeAws_queryGetSMSAttributesCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1661,8 +1675,7 @@ const deserializeAws_queryGetSMSSandboxAccountStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1675,10 +1688,12 @@ const deserializeAws_queryGetSMSSandboxAccountStatusCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1710,8 +1725,7 @@ const deserializeAws_queryGetSubscriptionAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1727,10 +1741,12 @@ const deserializeAws_queryGetSubscriptionAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1762,8 +1778,7 @@ const deserializeAws_queryGetTopicAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1782,10 +1797,12 @@ const deserializeAws_queryGetTopicAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1820,8 +1837,7 @@ const deserializeAws_queryListEndpointsByPlatformApplicationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1837,10 +1853,12 @@ const deserializeAws_queryListEndpointsByPlatformApplicationCommandError = async throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1872,8 +1890,7 @@ const deserializeAws_queryListOriginationNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1892,10 +1909,12 @@ const deserializeAws_queryListOriginationNumbersCommandError = async ( throw await deserializeAws_queryValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1927,8 +1946,7 @@ const deserializeAws_queryListPhoneNumbersOptedOutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1944,10 +1962,12 @@ const deserializeAws_queryListPhoneNumbersOptedOutCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1979,8 +1999,7 @@ const deserializeAws_queryListPlatformApplicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -1993,10 +2012,12 @@ const deserializeAws_queryListPlatformApplicationsCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2028,8 +2049,7 @@ const deserializeAws_queryListSMSSandboxPhoneNumbersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2048,10 +2068,12 @@ const deserializeAws_queryListSMSSandboxPhoneNumbersCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2083,8 +2105,7 @@ const deserializeAws_queryListSubscriptionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2097,10 +2118,12 @@ const deserializeAws_queryListSubscriptionsCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2132,8 +2155,7 @@ const deserializeAws_queryListSubscriptionsByTopicCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2149,10 +2171,12 @@ const deserializeAws_queryListSubscriptionsByTopicCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2184,8 +2208,7 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2204,10 +2227,12 @@ const deserializeAws_queryListTagsForResourceCommandError = async ( throw await deserializeAws_queryTagPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2239,8 +2264,7 @@ const deserializeAws_queryListTopicsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2253,10 +2277,12 @@ const deserializeAws_queryListTopicsCommandError = async ( throw await deserializeAws_queryInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2288,8 +2314,7 @@ const deserializeAws_queryOptInPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2305,10 +2330,12 @@ const deserializeAws_queryOptInPhoneNumberCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2340,8 +2367,7 @@ const deserializeAws_queryPublishCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2387,10 +2413,12 @@ const deserializeAws_queryPublishCommandError = async ( throw await deserializeAws_queryPlatformApplicationDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2422,8 +2450,7 @@ const deserializeAws_queryPublishBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2484,10 +2511,12 @@ const deserializeAws_queryPublishBatchCommandError = async ( throw await deserializeAws_queryTooManyEntriesInBatchRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2516,8 +2545,7 @@ const deserializeAws_queryRemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2533,10 +2561,12 @@ const deserializeAws_queryRemovePermissionCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2565,8 +2595,7 @@ const deserializeAws_querySetEndpointAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2582,10 +2611,12 @@ const deserializeAws_querySetEndpointAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2614,8 +2645,7 @@ const deserializeAws_querySetPlatformApplicationAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2631,10 +2661,12 @@ const deserializeAws_querySetPlatformApplicationAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2666,8 +2698,7 @@ const deserializeAws_querySetSMSAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2683,10 +2714,12 @@ const deserializeAws_querySetSMSAttributesCommandError = async ( throw await deserializeAws_queryThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2715,8 +2748,7 @@ const deserializeAws_querySetSubscriptionAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2735,10 +2767,12 @@ const deserializeAws_querySetSubscriptionAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2767,8 +2801,7 @@ const deserializeAws_querySetTopicAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2787,10 +2820,12 @@ const deserializeAws_querySetTopicAttributesCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2822,8 +2857,7 @@ const deserializeAws_querySubscribeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2848,10 +2882,12 @@ const deserializeAws_querySubscribeCommandError = async ( throw await deserializeAws_querySubscriptionLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2883,8 +2919,7 @@ const deserializeAws_queryTagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2909,10 +2944,12 @@ const deserializeAws_queryTagResourceCommandError = async ( throw await deserializeAws_queryTagPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2941,8 +2978,7 @@ const deserializeAws_queryUnsubscribeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -2961,10 +2997,12 @@ const deserializeAws_queryUnsubscribeCommandError = async ( throw await deserializeAws_queryNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2996,8 +3034,7 @@ const deserializeAws_queryUntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -3022,10 +3059,12 @@ const deserializeAws_queryUntagResourceCommandError = async ( throw await deserializeAws_queryTagPolicyExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3057,8 +3096,7 @@ const deserializeAws_queryVerifySMSSandboxPhoneNumberCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "AuthorizationErrorException": case "com.amazonaws.sns#AuthorizationErrorException": @@ -3080,10 +3118,12 @@ const deserializeAws_queryVerifySMSSandboxPhoneNumberCommandError = async ( throw await deserializeAws_queryVerificationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5517,12 +5557,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-sqs/src/protocols/Aws_query.ts b/clients/client-sqs/src/protocols/Aws_query.ts index f79cda57ba686..8d4fd989980f6 100644 --- a/clients/client-sqs/src/protocols/Aws_query.ts +++ b/clients/client-sqs/src/protocols/Aws_query.ts @@ -451,18 +451,19 @@ const deserializeAws_queryAddPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OverLimit": case "com.amazonaws.sqs#OverLimit": throw await deserializeAws_queryOverLimitResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -491,8 +492,7 @@ const deserializeAws_queryChangeMessageVisibilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "MessageNotInflight": case "com.amazonaws.sqs#MessageNotInflight": @@ -502,10 +502,12 @@ const deserializeAws_queryChangeMessageVisibilityCommandError = async ( throw await deserializeAws_queryReceiptHandleIsInvalidResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -537,8 +539,7 @@ const deserializeAws_queryChangeMessageVisibilityBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchEntryIdsNotDistinct": case "com.amazonaws.sqs#BatchEntryIdsNotDistinct": @@ -554,10 +555,12 @@ const deserializeAws_queryChangeMessageVisibilityBatchCommandError = async ( throw await deserializeAws_queryTooManyEntriesInBatchRequestResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -589,8 +592,7 @@ const deserializeAws_queryCreateQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "QueueDeletedRecently": case "com.amazonaws.sqs#QueueDeletedRecently": @@ -600,10 +602,12 @@ const deserializeAws_queryCreateQueueCommandError = async ( throw await deserializeAws_queryQueueNameExistsResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -632,8 +636,7 @@ const deserializeAws_queryDeleteMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidIdFormat": case "com.amazonaws.sqs#InvalidIdFormat": @@ -643,10 +646,12 @@ const deserializeAws_queryDeleteMessageCommandError = async ( throw await deserializeAws_queryReceiptHandleIsInvalidResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -678,8 +683,7 @@ const deserializeAws_queryDeleteMessageBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchEntryIdsNotDistinct": case "com.amazonaws.sqs#BatchEntryIdsNotDistinct": @@ -695,10 +699,12 @@ const deserializeAws_queryDeleteMessageBatchCommandError = async ( throw await deserializeAws_queryTooManyEntriesInBatchRequestResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -727,15 +733,16 @@ const deserializeAws_queryDeleteQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -767,18 +774,19 @@ const deserializeAws_queryGetQueueAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAttributeName": case "com.amazonaws.sqs#InvalidAttributeName": throw await deserializeAws_queryInvalidAttributeNameResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -810,18 +818,19 @@ const deserializeAws_queryGetQueueUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "QueueDoesNotExist": case "com.amazonaws.sqs#QueueDoesNotExist": throw await deserializeAws_queryQueueDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -853,18 +862,19 @@ const deserializeAws_queryListDeadLetterSourceQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "QueueDoesNotExist": case "com.amazonaws.sqs#QueueDoesNotExist": throw await deserializeAws_queryQueueDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -896,15 +906,16 @@ const deserializeAws_queryListQueuesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -936,15 +947,16 @@ const deserializeAws_queryListQueueTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -973,8 +985,7 @@ const deserializeAws_queryPurgeQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "PurgeQueueInProgress": case "com.amazonaws.sqs#PurgeQueueInProgress": @@ -984,10 +995,12 @@ const deserializeAws_queryPurgeQueueCommandError = async ( throw await deserializeAws_queryQueueDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1019,18 +1032,19 @@ const deserializeAws_queryReceiveMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "OverLimit": case "com.amazonaws.sqs#OverLimit": throw await deserializeAws_queryOverLimitResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1059,15 +1073,16 @@ const deserializeAws_queryRemovePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1099,8 +1114,7 @@ const deserializeAws_querySendMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidMessageContents": case "com.amazonaws.sqs#InvalidMessageContents": @@ -1110,10 +1124,12 @@ const deserializeAws_querySendMessageCommandError = async ( throw await deserializeAws_queryUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1145,8 +1161,7 @@ const deserializeAws_querySendMessageBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "BatchEntryIdsNotDistinct": case "com.amazonaws.sqs#BatchEntryIdsNotDistinct": @@ -1168,10 +1183,12 @@ const deserializeAws_querySendMessageBatchCommandError = async ( throw await deserializeAws_queryUnsupportedOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1200,18 +1217,19 @@ const deserializeAws_querySetQueueAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAttributeName": case "com.amazonaws.sqs#InvalidAttributeName": throw await deserializeAws_queryInvalidAttributeNameResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1240,15 +1258,16 @@ const deserializeAws_queryTagQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1277,15 +1296,16 @@ const deserializeAws_queryUntagQueueCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2845,12 +2865,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-ssm-contacts/src/protocols/Aws_json1_1.ts b/clients/client-ssm-contacts/src/protocols/Aws_json1_1.ts index 09ef9c261c7dc..558cba11904a8 100644 --- a/clients/client-ssm-contacts/src/protocols/Aws_json1_1.ts +++ b/clients/client-ssm-contacts/src/protocols/Aws_json1_1.ts @@ -525,8 +525,7 @@ const deserializeAws_json1_1AcceptPageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -545,10 +544,12 @@ const deserializeAws_json1_1AcceptPageCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -580,8 +581,7 @@ const deserializeAws_json1_1ActivateContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -600,10 +600,12 @@ const deserializeAws_json1_1ActivateContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -635,8 +637,7 @@ const deserializeAws_json1_1CreateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -661,10 +662,12 @@ const deserializeAws_json1_1CreateContactCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -696,8 +699,7 @@ const deserializeAws_json1_1CreateContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -719,10 +721,12 @@ const deserializeAws_json1_1CreateContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -754,8 +758,7 @@ const deserializeAws_json1_1DeactivateContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -774,10 +777,12 @@ const deserializeAws_json1_1DeactivateContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -809,8 +814,7 @@ const deserializeAws_json1_1DeleteContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -829,10 +833,12 @@ const deserializeAws_json1_1DeleteContactCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -864,8 +870,7 @@ const deserializeAws_json1_1DeleteContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -884,10 +889,12 @@ const deserializeAws_json1_1DeleteContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -919,8 +926,7 @@ const deserializeAws_json1_1DescribeEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -942,10 +948,12 @@ const deserializeAws_json1_1DescribeEngagementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -977,8 +985,7 @@ const deserializeAws_json1_1DescribePageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1000,10 +1007,12 @@ const deserializeAws_json1_1DescribePageCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1035,8 +1044,7 @@ const deserializeAws_json1_1GetContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1058,10 +1066,12 @@ const deserializeAws_json1_1GetContactCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1093,8 +1103,7 @@ const deserializeAws_json1_1GetContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1116,10 +1125,12 @@ const deserializeAws_json1_1GetContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1151,8 +1162,7 @@ const deserializeAws_json1_1GetContactPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1171,10 +1181,12 @@ const deserializeAws_json1_1GetContactPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1218,7 @@ const deserializeAws_json1_1ListContactChannelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1229,10 +1240,12 @@ const deserializeAws_json1_1ListContactChannelsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1264,8 +1277,7 @@ const deserializeAws_json1_1ListContactsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1281,10 +1293,12 @@ const deserializeAws_json1_1ListContactsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1316,8 +1330,7 @@ const deserializeAws_json1_1ListEngagementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1333,10 +1346,12 @@ const deserializeAws_json1_1ListEngagementsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1368,8 +1383,7 @@ const deserializeAws_json1_1ListPageReceiptsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1388,10 +1402,12 @@ const deserializeAws_json1_1ListPageReceiptsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1423,8 +1439,7 @@ const deserializeAws_json1_1ListPagesByContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1443,10 +1458,12 @@ const deserializeAws_json1_1ListPagesByContactCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1478,8 +1495,7 @@ const deserializeAws_json1_1ListPagesByEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1498,10 +1514,12 @@ const deserializeAws_json1_1ListPagesByEngagementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1533,8 +1551,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1553,10 +1570,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1588,8 +1607,7 @@ const deserializeAws_json1_1PutContactPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1611,10 +1629,12 @@ const deserializeAws_json1_1PutContactPolicyCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1646,8 +1666,7 @@ const deserializeAws_json1_1SendActivationCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1672,10 +1691,12 @@ const deserializeAws_json1_1SendActivationCodeCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1707,8 +1728,7 @@ const deserializeAws_json1_1StartEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1730,10 +1750,12 @@ const deserializeAws_json1_1StartEngagementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1765,8 +1787,7 @@ const deserializeAws_json1_1StopEngagementCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1785,10 +1806,12 @@ const deserializeAws_json1_1StopEngagementCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1820,8 +1843,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1843,10 +1865,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1878,8 +1902,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1898,10 +1921,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1933,8 +1958,7 @@ const deserializeAws_json1_1UpdateContactCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -1959,10 +1983,12 @@ const deserializeAws_json1_1UpdateContactCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1994,8 +2020,7 @@ const deserializeAws_json1_1UpdateContactChannelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmcontacts#AccessDeniedException": @@ -2020,10 +2045,12 @@ const deserializeAws_json1_1UpdateContactChannelCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3143,7 +3170,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3169,6 +3196,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ssm-incidents/src/protocols/Aws_restJson1.ts b/clients/client-ssm-incidents/src/protocols/Aws_restJson1.ts index 177fa2aa7d5ee..20dc91ec22a3b 100644 --- a/clients/client-ssm-incidents/src/protocols/Aws_restJson1.ts +++ b/clients/client-ssm-incidents/src/protocols/Aws_restJson1.ts @@ -983,8 +983,7 @@ const deserializeAws_restJson1CreateReplicationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1006,10 +1005,12 @@ const deserializeAws_restJson1CreateReplicationSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1042,8 +1043,7 @@ const deserializeAws_restJson1CreateResponsePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1065,10 +1065,12 @@ const deserializeAws_restJson1CreateResponsePlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1105,8 +1107,7 @@ const deserializeAws_restJson1CreateTimelineEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1128,10 +1129,12 @@ const deserializeAws_restJson1CreateTimelineEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1163,7 @@ const deserializeAws_restJson1DeleteIncidentRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1177,10 +1179,12 @@ const deserializeAws_restJson1DeleteIncidentRecordCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1213,7 @@ const deserializeAws_restJson1DeleteReplicationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1229,10 +1232,12 @@ const deserializeAws_restJson1DeleteReplicationSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,8 +1266,7 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1281,10 +1285,12 @@ const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1313,8 +1319,7 @@ const deserializeAws_restJson1DeleteResponsePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1330,10 +1335,12 @@ const deserializeAws_restJson1DeleteResponsePlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1362,8 +1369,7 @@ const deserializeAws_restJson1DeleteTimelineEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1379,10 +1385,12 @@ const deserializeAws_restJson1DeleteTimelineEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1415,8 +1423,7 @@ const deserializeAws_restJson1GetIncidentRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1435,10 +1442,12 @@ const deserializeAws_restJson1GetIncidentRecordCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1471,8 +1480,7 @@ const deserializeAws_restJson1GetReplicationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1491,10 +1499,12 @@ const deserializeAws_restJson1GetReplicationSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1531,8 +1541,7 @@ const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1551,10 +1560,12 @@ const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1611,8 +1622,7 @@ const deserializeAws_restJson1GetResponsePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1631,10 +1641,12 @@ const deserializeAws_restJson1GetResponsePlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1667,8 +1679,7 @@ const deserializeAws_restJson1GetTimelineEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1687,10 +1698,12 @@ const deserializeAws_restJson1GetTimelineEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1730,8 +1743,7 @@ const deserializeAws_restJson1ListIncidentRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1747,10 +1759,12 @@ const deserializeAws_restJson1ListIncidentRecordsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1787,8 +1801,7 @@ const deserializeAws_restJson1ListRelatedItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1804,10 +1817,12 @@ const deserializeAws_restJson1ListRelatedItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1844,8 +1859,7 @@ const deserializeAws_restJson1ListReplicationSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1861,10 +1875,12 @@ const deserializeAws_restJson1ListReplicationSetsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1904,8 +1920,7 @@ const deserializeAws_restJson1ListResponsePlansCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1921,10 +1936,12 @@ const deserializeAws_restJson1ListResponsePlansCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1957,8 +1974,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -1977,10 +1993,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2017,8 +2035,7 @@ const deserializeAws_restJson1ListTimelineEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2034,10 +2051,12 @@ const deserializeAws_restJson1ListTimelineEventsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2070,8 +2089,7 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2090,10 +2108,12 @@ const deserializeAws_restJson1PutResourcePolicyCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2126,8 +2146,7 @@ const deserializeAws_restJson1StartIncidentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2149,10 +2168,12 @@ const deserializeAws_restJson1StartIncidentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2181,8 +2202,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2207,10 +2227,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2239,8 +2261,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2262,10 +2283,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2294,8 +2317,7 @@ const deserializeAws_restJson1UpdateDeletionProtectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2314,10 +2336,12 @@ const deserializeAws_restJson1UpdateDeletionProtectionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2346,8 +2370,7 @@ const deserializeAws_restJson1UpdateIncidentRecordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2369,10 +2392,12 @@ const deserializeAws_restJson1UpdateIncidentRecordCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2401,8 +2426,7 @@ const deserializeAws_restJson1UpdateRelatedItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2424,10 +2448,12 @@ const deserializeAws_restJson1UpdateRelatedItemsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2456,8 +2482,7 @@ const deserializeAws_restJson1UpdateReplicationSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2479,10 +2504,12 @@ const deserializeAws_restJson1UpdateReplicationSetCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2511,8 +2538,7 @@ const deserializeAws_restJson1UpdateResponsePlanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2534,10 +2560,12 @@ const deserializeAws_restJson1UpdateResponsePlanCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2566,8 +2594,7 @@ const deserializeAws_restJson1UpdateTimelineEventCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssmincidents#AccessDeniedException": @@ -2589,10 +2616,12 @@ const deserializeAws_restJson1UpdateTimelineEventCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3584,7 +3613,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3610,6 +3639,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-ssm/src/protocols/Aws_json1_1.ts b/clients/client-ssm/src/protocols/Aws_json1_1.ts index be02e95e1489c..49fb09dc94e7d 100644 --- a/clients/client-ssm/src/protocols/Aws_json1_1.ts +++ b/clients/client-ssm/src/protocols/Aws_json1_1.ts @@ -2756,8 +2756,7 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -2776,10 +2775,12 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2811,8 +2812,7 @@ const deserializeAws_json1_1AssociateOpsItemRelatedItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -2831,10 +2831,12 @@ const deserializeAws_json1_1AssociateOpsItemRelatedItemCommandError = async ( throw await deserializeAws_json1_1OpsItemRelatedItemAlreadyExistsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2866,8 +2868,7 @@ const deserializeAws_json1_1CancelCommandCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateInstanceId": case "com.amazonaws.ssm#DuplicateInstanceId": @@ -2883,10 +2884,12 @@ const deserializeAws_json1_1CancelCommandCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2918,8 +2921,7 @@ const deserializeAws_json1_1CancelMaintenanceWindowExecutionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -2929,10 +2931,12 @@ const deserializeAws_json1_1CancelMaintenanceWindowExecutionCommandError = async throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2964,8 +2968,7 @@ const deserializeAws_json1_1CreateActivationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -2975,10 +2978,12 @@ const deserializeAws_json1_1CreateActivationCommandError = async ( throw await deserializeAws_json1_1InvalidParametersResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3010,8 +3015,7 @@ const deserializeAws_json1_1CreateAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationAlreadyExists": case "com.amazonaws.ssm#AssociationAlreadyExists": @@ -3051,10 +3055,12 @@ const deserializeAws_json1_1CreateAssociationCommandError = async ( throw await deserializeAws_json1_1UnsupportedPlatformTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3086,8 +3092,7 @@ const deserializeAws_json1_1CreateAssociationBatchCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationLimitExceeded": case "com.amazonaws.ssm#AssociationLimitExceeded": @@ -3127,10 +3132,12 @@ const deserializeAws_json1_1CreateAssociationBatchCommandError = async ( throw await deserializeAws_json1_1UnsupportedPlatformTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3162,8 +3169,7 @@ const deserializeAws_json1_1CreateDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentAlreadyExists": case "com.amazonaws.ssm#DocumentAlreadyExists": @@ -3185,10 +3191,12 @@ const deserializeAws_json1_1CreateDocumentCommandError = async ( throw await deserializeAws_json1_1MaxDocumentSizeExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3220,8 +3228,7 @@ const deserializeAws_json1_1CreateMaintenanceWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatch": case "com.amazonaws.ssm#IdempotentParameterMismatch": @@ -3234,10 +3241,12 @@ const deserializeAws_json1_1CreateMaintenanceWindowCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3269,8 +3278,7 @@ const deserializeAws_json1_1CreateOpsItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3286,10 +3294,12 @@ const deserializeAws_json1_1CreateOpsItemCommandError = async ( throw await deserializeAws_json1_1OpsItemLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3321,8 +3331,7 @@ const deserializeAws_json1_1CreateOpsMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3341,10 +3350,12 @@ const deserializeAws_json1_1CreateOpsMetadataCommandError = async ( throw await deserializeAws_json1_1OpsMetadataTooManyUpdatesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3376,8 +3387,7 @@ const deserializeAws_json1_1CreatePatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "IdempotentParameterMismatch": case "com.amazonaws.ssm#IdempotentParameterMismatch": @@ -3390,10 +3400,12 @@ const deserializeAws_json1_1CreatePatchBaselineCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3425,8 +3437,7 @@ const deserializeAws_json1_1CreateResourceDataSyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3442,10 +3453,12 @@ const deserializeAws_json1_1CreateResourceDataSyncCommandError = async ( throw await deserializeAws_json1_1ResourceDataSyncInvalidConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3477,8 +3490,7 @@ const deserializeAws_json1_1DeleteActivationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3494,10 +3506,12 @@ const deserializeAws_json1_1DeleteActivationCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3529,8 +3543,7 @@ const deserializeAws_json1_1DeleteAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -3549,10 +3562,12 @@ const deserializeAws_json1_1DeleteAssociationCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3584,8 +3599,7 @@ const deserializeAws_json1_1DeleteDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociatedInstances": case "com.amazonaws.ssm#AssociatedInstances": @@ -3601,10 +3615,12 @@ const deserializeAws_json1_1DeleteDocumentCommandError = async ( throw await deserializeAws_json1_1InvalidDocumentOperationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3636,8 +3652,7 @@ const deserializeAws_json1_1DeleteInventoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3656,10 +3671,12 @@ const deserializeAws_json1_1DeleteInventoryCommandError = async ( throw await deserializeAws_json1_1InvalidTypeNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3691,18 +3708,19 @@ const deserializeAws_json1_1DeleteMaintenanceWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3734,8 +3752,7 @@ const deserializeAws_json1_1DeleteOpsMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3748,10 +3765,12 @@ const deserializeAws_json1_1DeleteOpsMetadataCommandError = async ( throw await deserializeAws_json1_1OpsMetadataNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3783,8 +3802,7 @@ const deserializeAws_json1_1DeleteParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3794,10 +3812,12 @@ const deserializeAws_json1_1DeleteParameterCommandError = async ( throw await deserializeAws_json1_1ParameterNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3829,18 +3849,19 @@ const deserializeAws_json1_1DeleteParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3872,8 +3893,7 @@ const deserializeAws_json1_1DeletePatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3883,10 +3903,12 @@ const deserializeAws_json1_1DeletePatchBaselineCommandError = async ( throw await deserializeAws_json1_1ResourceInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3918,8 +3940,7 @@ const deserializeAws_json1_1DeleteResourceDataSyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3932,10 +3953,12 @@ const deserializeAws_json1_1DeleteResourceDataSyncCommandError = async ( throw await deserializeAws_json1_1ResourceDataSyncNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3967,8 +3990,7 @@ const deserializeAws_json1_1DeregisterManagedInstanceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -3978,10 +4000,12 @@ const deserializeAws_json1_1DeregisterManagedInstanceCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4013,8 +4037,7 @@ const deserializeAws_json1_1DeregisterPatchBaselineForPatchGroupCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4024,10 +4047,12 @@ const deserializeAws_json1_1DeregisterPatchBaselineForPatchGroupCommandError = a throw await deserializeAws_json1_1InvalidResourceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4059,8 +4084,7 @@ const deserializeAws_json1_1DeregisterTargetFromMaintenanceWindowCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -4073,10 +4097,12 @@ const deserializeAws_json1_1DeregisterTargetFromMaintenanceWindowCommandError = throw await deserializeAws_json1_1TargetInUseExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4108,8 +4134,7 @@ const deserializeAws_json1_1DeregisterTaskFromMaintenanceWindowCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -4119,10 +4144,12 @@ const deserializeAws_json1_1DeregisterTaskFromMaintenanceWindowCommandError = as throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4154,8 +4181,7 @@ const deserializeAws_json1_1DescribeActivationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4168,10 +4194,12 @@ const deserializeAws_json1_1DescribeActivationsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4203,8 +4231,7 @@ const deserializeAws_json1_1DescribeAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -4223,10 +4250,12 @@ const deserializeAws_json1_1DescribeAssociationCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4258,8 +4287,7 @@ const deserializeAws_json1_1DescribeAssociationExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -4272,10 +4300,12 @@ const deserializeAws_json1_1DescribeAssociationExecutionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4307,8 +4337,7 @@ const deserializeAws_json1_1DescribeAssociationExecutionTargetsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -4324,10 +4353,12 @@ const deserializeAws_json1_1DescribeAssociationExecutionTargetsCommandError = as throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4359,8 +4390,7 @@ const deserializeAws_json1_1DescribeAutomationExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4376,10 +4406,12 @@ const deserializeAws_json1_1DescribeAutomationExecutionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4411,8 +4443,7 @@ const deserializeAws_json1_1DescribeAutomationStepExecutionsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationExecutionNotFoundException": case "com.amazonaws.ssm#AutomationExecutionNotFoundException": @@ -4431,10 +4462,12 @@ const deserializeAws_json1_1DescribeAutomationStepExecutionsCommandError = async throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4466,18 +4499,19 @@ const deserializeAws_json1_1DescribeAvailablePatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4509,8 +4543,7 @@ const deserializeAws_json1_1DescribeDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4523,10 +4556,12 @@ const deserializeAws_json1_1DescribeDocumentCommandError = async ( throw await deserializeAws_json1_1InvalidDocumentVersionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4558,8 +4593,7 @@ const deserializeAws_json1_1DescribeDocumentPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4578,10 +4612,12 @@ const deserializeAws_json1_1DescribeDocumentPermissionCommandError = async ( throw await deserializeAws_json1_1InvalidPermissionTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4613,8 +4649,7 @@ const deserializeAws_json1_1DescribeEffectiveInstanceAssociationsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4627,10 +4662,12 @@ const deserializeAws_json1_1DescribeEffectiveInstanceAssociationsCommandError = throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4662,8 +4699,7 @@ const deserializeAws_json1_1DescribeEffectivePatchesForPatchBaselineCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -4679,10 +4715,12 @@ const deserializeAws_json1_1DescribeEffectivePatchesForPatchBaselineCommandError throw await deserializeAws_json1_1UnsupportedOperatingSystemResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4714,8 +4752,7 @@ const deserializeAws_json1_1DescribeInstanceAssociationsStatusCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4728,10 +4765,12 @@ const deserializeAws_json1_1DescribeInstanceAssociationsStatusCommandError = asy throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4763,8 +4802,7 @@ const deserializeAws_json1_1DescribeInstanceInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4783,10 +4821,12 @@ const deserializeAws_json1_1DescribeInstanceInformationCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4818,8 +4858,7 @@ const deserializeAws_json1_1DescribeInstancePatchesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4835,10 +4874,12 @@ const deserializeAws_json1_1DescribeInstancePatchesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4870,8 +4911,7 @@ const deserializeAws_json1_1DescribeInstancePatchStatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4881,10 +4921,12 @@ const deserializeAws_json1_1DescribeInstancePatchStatesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4916,8 +4958,7 @@ const deserializeAws_json1_1DescribeInstancePatchStatesForPatchGroupCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4930,10 +4971,12 @@ const deserializeAws_json1_1DescribeInstancePatchStatesForPatchGroupCommandError throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4965,8 +5008,7 @@ const deserializeAws_json1_1DescribeInventoryDeletionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -4979,10 +5021,12 @@ const deserializeAws_json1_1DescribeInventoryDeletionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5014,18 +5058,19 @@ const deserializeAws_json1_1DescribeMaintenanceWindowExecutionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5057,8 +5102,7 @@ const deserializeAws_json1_1DescribeMaintenanceWindowExecutionTaskInvocationsCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -5068,10 +5112,12 @@ const deserializeAws_json1_1DescribeMaintenanceWindowExecutionTaskInvocationsCom throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5103,8 +5149,7 @@ const deserializeAws_json1_1DescribeMaintenanceWindowExecutionTasksCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -5114,10 +5159,12 @@ const deserializeAws_json1_1DescribeMaintenanceWindowExecutionTasksCommandError throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5149,18 +5196,19 @@ const deserializeAws_json1_1DescribeMaintenanceWindowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5192,8 +5240,7 @@ const deserializeAws_json1_1DescribeMaintenanceWindowScheduleCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -5203,10 +5250,12 @@ const deserializeAws_json1_1DescribeMaintenanceWindowScheduleCommandError = asyn throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5238,18 +5287,19 @@ const deserializeAws_json1_1DescribeMaintenanceWindowsForTargetCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5281,8 +5331,7 @@ const deserializeAws_json1_1DescribeMaintenanceWindowTargetsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -5292,10 +5341,12 @@ const deserializeAws_json1_1DescribeMaintenanceWindowTargetsCommandError = async throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5327,8 +5378,7 @@ const deserializeAws_json1_1DescribeMaintenanceWindowTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -5338,10 +5388,12 @@ const deserializeAws_json1_1DescribeMaintenanceWindowTasksCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5373,18 +5425,19 @@ const deserializeAws_json1_1DescribeOpsItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5416,8 +5469,7 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5436,10 +5488,12 @@ const deserializeAws_json1_1DescribeParametersCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5471,18 +5525,19 @@ const deserializeAws_json1_1DescribePatchBaselinesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5514,18 +5569,19 @@ const deserializeAws_json1_1DescribePatchGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5557,8 +5613,7 @@ const deserializeAws_json1_1DescribePatchGroupStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5568,10 +5623,12 @@ const deserializeAws_json1_1DescribePatchGroupStateCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5603,18 +5660,19 @@ const deserializeAws_json1_1DescribePatchPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5646,8 +5704,7 @@ const deserializeAws_json1_1DescribeSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5660,10 +5717,12 @@ const deserializeAws_json1_1DescribeSessionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5695,8 +5754,7 @@ const deserializeAws_json1_1DisassociateOpsItemRelatedItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5712,10 +5770,12 @@ const deserializeAws_json1_1DisassociateOpsItemRelatedItemCommandError = async ( throw await deserializeAws_json1_1OpsItemRelatedItemAssociationNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5747,8 +5807,7 @@ const deserializeAws_json1_1GetAutomationExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationExecutionNotFoundException": case "com.amazonaws.ssm#AutomationExecutionNotFoundException": @@ -5758,10 +5817,12 @@ const deserializeAws_json1_1GetAutomationExecutionCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5793,8 +5854,7 @@ const deserializeAws_json1_1GetCalendarStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5810,10 +5870,12 @@ const deserializeAws_json1_1GetCalendarStateCommandError = async ( throw await deserializeAws_json1_1UnsupportedCalendarExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5845,8 +5907,7 @@ const deserializeAws_json1_1GetCommandInvocationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -5865,10 +5926,12 @@ const deserializeAws_json1_1GetCommandInvocationCommandError = async ( throw await deserializeAws_json1_1InvocationDoesNotExistResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5900,18 +5963,19 @@ const deserializeAws_json1_1GetConnectionStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5943,18 +6007,19 @@ const deserializeAws_json1_1GetDefaultPatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5986,8 +6051,7 @@ const deserializeAws_json1_1GetDeployablePatchSnapshotForInstanceCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6000,10 +6064,12 @@ const deserializeAws_json1_1GetDeployablePatchSnapshotForInstanceCommandError = throw await deserializeAws_json1_1UnsupportedOperatingSystemResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6035,8 +6101,7 @@ const deserializeAws_json1_1GetDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6049,10 +6114,12 @@ const deserializeAws_json1_1GetDocumentCommandError = async ( throw await deserializeAws_json1_1InvalidDocumentVersionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6084,8 +6151,7 @@ const deserializeAws_json1_1GetInventoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6110,10 +6176,12 @@ const deserializeAws_json1_1GetInventoryCommandError = async ( throw await deserializeAws_json1_1InvalidTypeNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6145,8 +6213,7 @@ const deserializeAws_json1_1GetInventorySchemaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6159,10 +6226,12 @@ const deserializeAws_json1_1GetInventorySchemaCommandError = async ( throw await deserializeAws_json1_1InvalidTypeNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6194,8 +6263,7 @@ const deserializeAws_json1_1GetMaintenanceWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6205,10 +6273,12 @@ const deserializeAws_json1_1GetMaintenanceWindowCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6240,8 +6310,7 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6251,10 +6320,12 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6286,8 +6357,7 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionTaskCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6297,10 +6367,12 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionTaskCommandError = asyn throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6332,8 +6404,7 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionTaskInvocationCommandEr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6343,10 +6414,12 @@ const deserializeAws_json1_1GetMaintenanceWindowExecutionTaskInvocationCommandEr throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6378,8 +6451,7 @@ const deserializeAws_json1_1GetMaintenanceWindowTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6389,10 +6461,12 @@ const deserializeAws_json1_1GetMaintenanceWindowTaskCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6424,8 +6498,7 @@ const deserializeAws_json1_1GetOpsItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6435,10 +6508,12 @@ const deserializeAws_json1_1GetOpsItemCommandError = async ( throw await deserializeAws_json1_1OpsItemNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6470,8 +6545,7 @@ const deserializeAws_json1_1GetOpsMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6484,10 +6558,12 @@ const deserializeAws_json1_1GetOpsMetadataCommandError = async ( throw await deserializeAws_json1_1OpsMetadataNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6519,8 +6595,7 @@ const deserializeAws_json1_1GetOpsSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6542,10 +6617,12 @@ const deserializeAws_json1_1GetOpsSummaryCommandError = async ( throw await deserializeAws_json1_1ResourceDataSyncNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6577,8 +6654,7 @@ const deserializeAws_json1_1GetParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6594,10 +6670,12 @@ const deserializeAws_json1_1GetParameterCommandError = async ( throw await deserializeAws_json1_1ParameterVersionNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6629,8 +6707,7 @@ const deserializeAws_json1_1GetParameterHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6646,10 +6723,12 @@ const deserializeAws_json1_1GetParameterHistoryCommandError = async ( throw await deserializeAws_json1_1ParameterNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6681,8 +6760,7 @@ const deserializeAws_json1_1GetParametersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6692,10 +6770,12 @@ const deserializeAws_json1_1GetParametersCommandError = async ( throw await deserializeAws_json1_1InvalidKeyIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6727,8 +6807,7 @@ const deserializeAws_json1_1GetParametersByPathCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6750,10 +6829,12 @@ const deserializeAws_json1_1GetParametersByPathCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6785,8 +6866,7 @@ const deserializeAws_json1_1GetPatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -6799,10 +6879,12 @@ const deserializeAws_json1_1GetPatchBaselineCommandError = async ( throw await deserializeAws_json1_1InvalidResourceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6834,18 +6916,19 @@ const deserializeAws_json1_1GetPatchBaselineForPatchGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6877,8 +6960,7 @@ const deserializeAws_json1_1GetServiceSettingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6888,10 +6970,12 @@ const deserializeAws_json1_1GetServiceSettingCommandError = async ( throw await deserializeAws_json1_1ServiceSettingNotFoundResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6923,8 +7007,7 @@ const deserializeAws_json1_1LabelParameterVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6943,10 +7026,12 @@ const deserializeAws_json1_1LabelParameterVersionCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6978,8 +7063,7 @@ const deserializeAws_json1_1ListAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -6989,10 +7073,12 @@ const deserializeAws_json1_1ListAssociationsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7024,8 +7110,7 @@ const deserializeAws_json1_1ListAssociationVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -7038,10 +7123,12 @@ const deserializeAws_json1_1ListAssociationVersionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7073,8 +7160,7 @@ const deserializeAws_json1_1ListCommandInvocationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7093,10 +7179,12 @@ const deserializeAws_json1_1ListCommandInvocationsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7128,8 +7216,7 @@ const deserializeAws_json1_1ListCommandsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7148,10 +7235,12 @@ const deserializeAws_json1_1ListCommandsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7183,8 +7272,7 @@ const deserializeAws_json1_1ListComplianceItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7203,10 +7291,12 @@ const deserializeAws_json1_1ListComplianceItemsCommandError = async ( throw await deserializeAws_json1_1InvalidResourceTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7238,8 +7328,7 @@ const deserializeAws_json1_1ListComplianceSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7252,10 +7341,12 @@ const deserializeAws_json1_1ListComplianceSummariesCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7287,8 +7378,7 @@ const deserializeAws_json1_1ListDocumentMetadataHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7304,10 +7394,12 @@ const deserializeAws_json1_1ListDocumentMetadataHistoryCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7339,8 +7431,7 @@ const deserializeAws_json1_1ListDocumentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7353,10 +7444,12 @@ const deserializeAws_json1_1ListDocumentsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7388,8 +7481,7 @@ const deserializeAws_json1_1ListDocumentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7402,10 +7494,12 @@ const deserializeAws_json1_1ListDocumentVersionsCommandError = async ( throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7437,8 +7531,7 @@ const deserializeAws_json1_1ListInventoryEntriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7457,10 +7550,12 @@ const deserializeAws_json1_1ListInventoryEntriesCommandError = async ( throw await deserializeAws_json1_1InvalidTypeNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7492,8 +7587,7 @@ const deserializeAws_json1_1ListOpsItemEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7509,10 +7603,12 @@ const deserializeAws_json1_1ListOpsItemEventsCommandError = async ( throw await deserializeAws_json1_1OpsItemNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7544,8 +7640,7 @@ const deserializeAws_json1_1ListOpsItemRelatedItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7555,10 +7650,12 @@ const deserializeAws_json1_1ListOpsItemRelatedItemsCommandError = async ( throw await deserializeAws_json1_1OpsItemInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7590,8 +7687,7 @@ const deserializeAws_json1_1ListOpsMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7601,10 +7697,12 @@ const deserializeAws_json1_1ListOpsMetadataCommandError = async ( throw await deserializeAws_json1_1OpsMetadataInvalidArgumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7636,8 +7734,7 @@ const deserializeAws_json1_1ListResourceComplianceSummariesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7650,10 +7747,12 @@ const deserializeAws_json1_1ListResourceComplianceSummariesCommandError = async throw await deserializeAws_json1_1InvalidNextTokenResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7685,8 +7784,7 @@ const deserializeAws_json1_1ListResourceDataSyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7699,10 +7797,12 @@ const deserializeAws_json1_1ListResourceDataSyncCommandError = async ( throw await deserializeAws_json1_1ResourceDataSyncInvalidConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7734,8 +7834,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -7748,10 +7847,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InvalidResourceTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7783,8 +7884,7 @@ const deserializeAws_json1_1ModifyDocumentPermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentLimitExceeded": case "com.amazonaws.ssm#DocumentLimitExceeded": @@ -7803,10 +7903,12 @@ const deserializeAws_json1_1ModifyDocumentPermissionCommandError = async ( throw await deserializeAws_json1_1InvalidPermissionTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7838,8 +7940,7 @@ const deserializeAws_json1_1PutComplianceItemsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplianceTypeCountLimitExceededException": case "com.amazonaws.ssm#ComplianceTypeCountLimitExceededException": @@ -7864,10 +7965,12 @@ const deserializeAws_json1_1PutComplianceItemsCommandError = async ( throw await deserializeAws_json1_1TotalSizeLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7899,8 +8002,7 @@ const deserializeAws_json1_1PutInventoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomSchemaCountLimitExceededException": case "com.amazonaws.ssm#CustomSchemaCountLimitExceededException": @@ -7940,10 +8042,12 @@ const deserializeAws_json1_1PutInventoryCommandError = async ( throw await deserializeAws_json1_1UnsupportedInventorySchemaVersionExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7975,8 +8079,7 @@ const deserializeAws_json1_1PutParameterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "HierarchyLevelLimitExceededException": case "com.amazonaws.ssm#HierarchyLevelLimitExceededException": @@ -8025,10 +8128,12 @@ const deserializeAws_json1_1PutParameterCommandError = async ( throw await deserializeAws_json1_1UnsupportedParameterTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8060,8 +8165,7 @@ const deserializeAws_json1_1RegisterDefaultPatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -8074,10 +8178,12 @@ const deserializeAws_json1_1RegisterDefaultPatchBaselineCommandError = async ( throw await deserializeAws_json1_1InvalidResourceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8109,8 +8215,7 @@ const deserializeAws_json1_1RegisterPatchBaselineForPatchGroupCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AlreadyExistsException": case "com.amazonaws.ssm#AlreadyExistsException": @@ -8129,10 +8234,12 @@ const deserializeAws_json1_1RegisterPatchBaselineForPatchGroupCommandError = asy throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8164,8 +8271,7 @@ const deserializeAws_json1_1RegisterTargetWithMaintenanceWindowCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -8181,10 +8287,12 @@ const deserializeAws_json1_1RegisterTargetWithMaintenanceWindowCommandError = as throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8216,8 +8324,7 @@ const deserializeAws_json1_1RegisterTaskWithMaintenanceWindowCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -8236,10 +8343,12 @@ const deserializeAws_json1_1RegisterTaskWithMaintenanceWindowCommandError = asyn throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8271,8 +8380,7 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -8288,10 +8396,12 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8323,8 +8433,7 @@ const deserializeAws_json1_1ResetServiceSettingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -8337,10 +8446,12 @@ const deserializeAws_json1_1ResetServiceSettingCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8372,8 +8483,7 @@ const deserializeAws_json1_1ResumeSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -8383,10 +8493,12 @@ const deserializeAws_json1_1ResumeSessionCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8418,8 +8530,7 @@ const deserializeAws_json1_1SendAutomationSignalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationExecutionNotFoundException": case "com.amazonaws.ssm#AutomationExecutionNotFoundException": @@ -8435,10 +8546,12 @@ const deserializeAws_json1_1SendAutomationSignalCommandError = async ( throw await deserializeAws_json1_1InvalidAutomationSignalExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8470,8 +8583,7 @@ const deserializeAws_json1_1SendCommandCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DuplicateInstanceId": case "com.amazonaws.ssm#DuplicateInstanceId": @@ -8508,10 +8620,12 @@ const deserializeAws_json1_1SendCommandCommandError = async ( throw await deserializeAws_json1_1UnsupportedPlatformTypeResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8543,8 +8657,7 @@ const deserializeAws_json1_1StartAssociationsOnceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -8554,10 +8667,12 @@ const deserializeAws_json1_1StartAssociationsOnceCommandError = async ( throw await deserializeAws_json1_1InvalidAssociationResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8589,8 +8704,7 @@ const deserializeAws_json1_1StartAutomationExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationDefinitionNotFoundException": case "com.amazonaws.ssm#AutomationDefinitionNotFoundException": @@ -8615,10 +8729,12 @@ const deserializeAws_json1_1StartAutomationExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidTargetResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8650,8 +8766,7 @@ const deserializeAws_json1_1StartChangeRequestExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationDefinitionNotApprovedException": case "com.amazonaws.ssm#AutomationDefinitionNotApprovedException": @@ -8676,10 +8791,12 @@ const deserializeAws_json1_1StartChangeRequestExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidAutomationExecutionParametersExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8711,8 +8828,7 @@ const deserializeAws_json1_1StartSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -8725,10 +8841,12 @@ const deserializeAws_json1_1StartSessionCommandError = async ( throw await deserializeAws_json1_1TargetNotConnectedResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8760,8 +8878,7 @@ const deserializeAws_json1_1StopAutomationExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AutomationExecutionNotFoundException": case "com.amazonaws.ssm#AutomationExecutionNotFoundException": @@ -8774,10 +8891,12 @@ const deserializeAws_json1_1StopAutomationExecutionCommandError = async ( throw await deserializeAws_json1_1InvalidAutomationStatusUpdateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8809,18 +8928,19 @@ const deserializeAws_json1_1TerminateSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8852,8 +8972,7 @@ const deserializeAws_json1_1UnlabelParameterVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -8869,10 +8988,12 @@ const deserializeAws_json1_1UnlabelParameterVersionCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8904,8 +9025,7 @@ const deserializeAws_json1_1UpdateAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -8948,10 +9068,12 @@ const deserializeAws_json1_1UpdateAssociationCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8983,8 +9105,7 @@ const deserializeAws_json1_1UpdateAssociationStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AssociationDoesNotExist": case "com.amazonaws.ssm#AssociationDoesNotExist": @@ -9006,10 +9127,12 @@ const deserializeAws_json1_1UpdateAssociationStatusCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9041,8 +9164,7 @@ const deserializeAws_json1_1UpdateDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentVersionLimitExceeded": case "com.amazonaws.ssm#DocumentVersionLimitExceeded": @@ -9076,10 +9198,12 @@ const deserializeAws_json1_1UpdateDocumentCommandError = async ( throw await deserializeAws_json1_1MaxDocumentSizeExceededResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9111,8 +9235,7 @@ const deserializeAws_json1_1UpdateDocumentDefaultVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9128,10 +9251,12 @@ const deserializeAws_json1_1UpdateDocumentDefaultVersionCommandError = async ( throw await deserializeAws_json1_1InvalidDocumentVersionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9163,8 +9288,7 @@ const deserializeAws_json1_1UpdateDocumentMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9180,10 +9304,12 @@ const deserializeAws_json1_1UpdateDocumentMetadataCommandError = async ( throw await deserializeAws_json1_1InvalidDocumentVersionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9215,8 +9341,7 @@ const deserializeAws_json1_1UpdateMaintenanceWindowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -9226,10 +9351,12 @@ const deserializeAws_json1_1UpdateMaintenanceWindowCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9261,8 +9388,7 @@ const deserializeAws_json1_1UpdateMaintenanceWindowTargetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -9272,10 +9398,12 @@ const deserializeAws_json1_1UpdateMaintenanceWindowTargetCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9307,8 +9435,7 @@ const deserializeAws_json1_1UpdateMaintenanceWindowTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -9318,10 +9445,12 @@ const deserializeAws_json1_1UpdateMaintenanceWindowTaskCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9353,8 +9482,7 @@ const deserializeAws_json1_1UpdateManagedInstanceRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9364,10 +9492,12 @@ const deserializeAws_json1_1UpdateManagedInstanceRoleCommandError = async ( throw await deserializeAws_json1_1InvalidInstanceIdResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9399,8 +9529,7 @@ const deserializeAws_json1_1UpdateOpsItemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9419,10 +9548,12 @@ const deserializeAws_json1_1UpdateOpsItemCommandError = async ( throw await deserializeAws_json1_1OpsItemNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9454,8 +9585,7 @@ const deserializeAws_json1_1UpdateOpsMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9474,10 +9604,12 @@ const deserializeAws_json1_1UpdateOpsMetadataCommandError = async ( throw await deserializeAws_json1_1OpsMetadataTooManyUpdatesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9509,8 +9641,7 @@ const deserializeAws_json1_1UpdatePatchBaselineCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DoesNotExistException": case "com.amazonaws.ssm#DoesNotExistException": @@ -9520,10 +9651,12 @@ const deserializeAws_json1_1UpdatePatchBaselineCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9555,8 +9688,7 @@ const deserializeAws_json1_1UpdateResourceDataSyncCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9572,10 +9704,12 @@ const deserializeAws_json1_1UpdateResourceDataSyncCommandError = async ( throw await deserializeAws_json1_1ResourceDataSyncNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9607,8 +9741,7 @@ const deserializeAws_json1_1UpdateServiceSettingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.ssm#InternalServerError": @@ -9621,10 +9754,12 @@ const deserializeAws_json1_1UpdateServiceSettingCommandError = async ( throw await deserializeAws_json1_1TooManyUpdatesResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -21511,7 +21646,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -21537,6 +21672,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sso-admin/src/protocols/Aws_json1_1.ts b/clients/client-sso-admin/src/protocols/Aws_json1_1.ts index 76f5fa5a1c50d..c19e96cd132a1 100644 --- a/clients/client-sso-admin/src/protocols/Aws_json1_1.ts +++ b/clients/client-sso-admin/src/protocols/Aws_json1_1.ts @@ -641,8 +641,7 @@ const deserializeAws_json1_1AttachManagedPolicyToPermissionSetCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -667,10 +666,12 @@ const deserializeAws_json1_1AttachManagedPolicyToPermissionSetCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -702,8 +703,7 @@ const deserializeAws_json1_1CreateAccountAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -728,10 +728,12 @@ const deserializeAws_json1_1CreateAccountAssignmentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -763,8 +765,7 @@ const deserializeAws_json1_1CreateInstanceAccessControlAttributeConfigurationCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -786,10 +787,12 @@ const deserializeAws_json1_1CreateInstanceAccessControlAttributeConfigurationCom throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -821,8 +824,7 @@ const deserializeAws_json1_1CreatePermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -847,10 +849,12 @@ const deserializeAws_json1_1CreatePermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -882,8 +886,7 @@ const deserializeAws_json1_1DeleteAccountAssignmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -905,10 +908,12 @@ const deserializeAws_json1_1DeleteAccountAssignmentCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -940,8 +945,7 @@ const deserializeAws_json1_1DeleteInlinePolicyFromPermissionSetCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -963,10 +967,12 @@ const deserializeAws_json1_1DeleteInlinePolicyFromPermissionSetCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -998,8 +1004,7 @@ const deserializeAws_json1_1DeleteInstanceAccessControlAttributeConfigurationCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1021,10 +1026,12 @@ const deserializeAws_json1_1DeleteInstanceAccessControlAttributeConfigurationCom throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1056,8 +1063,7 @@ const deserializeAws_json1_1DeletePermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1079,10 +1085,12 @@ const deserializeAws_json1_1DeletePermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1114,8 +1122,7 @@ const deserializeAws_json1_1DescribeAccountAssignmentCreationStatusCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1134,10 +1141,12 @@ const deserializeAws_json1_1DescribeAccountAssignmentCreationStatusCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1169,8 +1178,7 @@ const deserializeAws_json1_1DescribeAccountAssignmentDeletionStatusCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1189,10 +1197,12 @@ const deserializeAws_json1_1DescribeAccountAssignmentDeletionStatusCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1224,8 +1234,7 @@ const deserializeAws_json1_1DescribeInstanceAccessControlAttributeConfigurationC body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1244,10 +1253,12 @@ const deserializeAws_json1_1DescribeInstanceAccessControlAttributeConfigurationC throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1279,8 +1290,7 @@ const deserializeAws_json1_1DescribePermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1299,10 +1309,12 @@ const deserializeAws_json1_1DescribePermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1334,8 +1346,7 @@ const deserializeAws_json1_1DescribePermissionSetProvisioningStatusCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1354,10 +1365,12 @@ const deserializeAws_json1_1DescribePermissionSetProvisioningStatusCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1389,8 +1402,7 @@ const deserializeAws_json1_1DetachManagedPolicyFromPermissionSetCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1412,10 +1424,12 @@ const deserializeAws_json1_1DetachManagedPolicyFromPermissionSetCommandError = a throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1447,8 +1461,7 @@ const deserializeAws_json1_1GetInlinePolicyForPermissionSetCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1467,10 +1480,12 @@ const deserializeAws_json1_1GetInlinePolicyForPermissionSetCommandError = async throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1502,8 +1517,7 @@ const deserializeAws_json1_1ListAccountAssignmentCreationStatusCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1522,10 +1536,12 @@ const deserializeAws_json1_1ListAccountAssignmentCreationStatusCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1557,8 +1573,7 @@ const deserializeAws_json1_1ListAccountAssignmentDeletionStatusCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1577,10 +1592,12 @@ const deserializeAws_json1_1ListAccountAssignmentDeletionStatusCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1612,8 +1629,7 @@ const deserializeAws_json1_1ListAccountAssignmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1632,10 +1648,12 @@ const deserializeAws_json1_1ListAccountAssignmentsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1667,8 +1685,7 @@ const deserializeAws_json1_1ListAccountsForProvisionedPermissionSetCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1687,10 +1704,12 @@ const deserializeAws_json1_1ListAccountsForProvisionedPermissionSetCommandError throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1722,8 +1741,7 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1739,10 +1757,12 @@ const deserializeAws_json1_1ListInstancesCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1774,8 +1794,7 @@ const deserializeAws_json1_1ListManagedPoliciesInPermissionSetCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1794,10 +1813,12 @@ const deserializeAws_json1_1ListManagedPoliciesInPermissionSetCommandError = asy throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1829,8 +1850,7 @@ const deserializeAws_json1_1ListPermissionSetProvisioningStatusCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1849,10 +1869,12 @@ const deserializeAws_json1_1ListPermissionSetProvisioningStatusCommandError = as throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1884,8 +1906,7 @@ const deserializeAws_json1_1ListPermissionSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1904,10 +1925,12 @@ const deserializeAws_json1_1ListPermissionSetsCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1939,8 +1962,7 @@ const deserializeAws_json1_1ListPermissionSetsProvisionedToAccountCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -1959,10 +1981,12 @@ const deserializeAws_json1_1ListPermissionSetsProvisionedToAccountCommandError = throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1994,8 +2018,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2014,10 +2037,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2049,8 +2074,7 @@ const deserializeAws_json1_1ProvisionPermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2072,10 +2096,12 @@ const deserializeAws_json1_1ProvisionPermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2107,8 +2133,7 @@ const deserializeAws_json1_1PutInlinePolicyToPermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2133,10 +2158,12 @@ const deserializeAws_json1_1PutInlinePolicyToPermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2168,8 +2195,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2194,10 +2220,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2229,8 +2257,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2252,10 +2279,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2287,8 +2316,7 @@ const deserializeAws_json1_1UpdateInstanceAccessControlAttributeConfigurationCom body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2310,10 +2338,12 @@ const deserializeAws_json1_1UpdateInstanceAccessControlAttributeConfigurationCom throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2345,8 +2375,7 @@ const deserializeAws_json1_1UpdatePermissionSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssoadmin#AccessDeniedException": @@ -2368,10 +2397,12 @@ const deserializeAws_json1_1UpdatePermissionSetCommandError = async ( throw await deserializeAws_json1_1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3650,7 +3681,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3676,6 +3707,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sso-oidc/src/protocols/Aws_restJson1.ts b/clients/client-sso-oidc/src/protocols/Aws_restJson1.ts index a5526f621454a..10ea0e994ed0a 100644 --- a/clients/client-sso-oidc/src/protocols/Aws_restJson1.ts +++ b/clients/client-sso-oidc/src/protocols/Aws_restJson1.ts @@ -164,8 +164,7 @@ const deserializeAws_restJson1CreateTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.ssooidc#AccessDeniedException": @@ -202,10 +201,12 @@ const deserializeAws_restJson1CreateTokenCommandError = async ( throw await deserializeAws_restJson1UnsupportedGrantTypeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -258,8 +259,7 @@ const deserializeAws_restJson1RegisterClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ssooidc#InternalServerException": @@ -275,10 +275,12 @@ const deserializeAws_restJson1RegisterClientCommandError = async ( throw await deserializeAws_restJson1InvalidScopeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -331,8 +333,7 @@ const deserializeAws_restJson1StartDeviceAuthorizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.ssooidc#InternalServerException": @@ -351,10 +352,12 @@ const deserializeAws_restJson1StartDeviceAuthorizationCommandError = async ( throw await deserializeAws_restJson1UnauthorizedClientExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -636,7 +639,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -662,6 +665,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sso/src/protocols/Aws_restJson1.ts b/clients/client-sso/src/protocols/Aws_restJson1.ts index 2b5e389bf3913..6bb70b7453b3e 100644 --- a/clients/client-sso/src/protocols/Aws_restJson1.ts +++ b/clients/client-sso/src/protocols/Aws_restJson1.ts @@ -157,8 +157,7 @@ const deserializeAws_restJson1GetRoleCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.sso#InvalidRequestException": @@ -174,10 +173,12 @@ const deserializeAws_restJson1GetRoleCredentialsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -214,8 +215,7 @@ const deserializeAws_restJson1ListAccountRolesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.sso#InvalidRequestException": @@ -231,10 +231,12 @@ const deserializeAws_restJson1ListAccountRolesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -271,8 +273,7 @@ const deserializeAws_restJson1ListAccountsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.sso#InvalidRequestException": @@ -288,10 +289,12 @@ const deserializeAws_restJson1ListAccountsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -320,8 +323,7 @@ const deserializeAws_restJson1LogoutCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.sso#InvalidRequestException": @@ -334,10 +336,12 @@ const deserializeAws_restJson1LogoutCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -492,7 +496,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -518,6 +522,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-storage-gateway/src/protocols/Aws_json1_1.ts b/clients/client-storage-gateway/src/protocols/Aws_json1_1.ts index 3d75db571b2c5..1c4e06c1476cd 100644 --- a/clients/client-storage-gateway/src/protocols/Aws_json1_1.ts +++ b/clients/client-storage-gateway/src/protocols/Aws_json1_1.ts @@ -1676,8 +1676,7 @@ const deserializeAws_json1_1ActivateGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1687,10 +1686,12 @@ const deserializeAws_json1_1ActivateGatewayCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1722,8 +1723,7 @@ const deserializeAws_json1_1AddCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1733,10 +1733,12 @@ const deserializeAws_json1_1AddCacheCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1768,8 +1770,7 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1779,10 +1780,12 @@ const deserializeAws_json1_1AddTagsToResourceCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1814,8 +1817,7 @@ const deserializeAws_json1_1AddUploadBufferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1825,10 +1827,12 @@ const deserializeAws_json1_1AddUploadBufferCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1860,8 +1864,7 @@ const deserializeAws_json1_1AddWorkingStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1871,10 +1874,12 @@ const deserializeAws_json1_1AddWorkingStorageCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1906,8 +1911,7 @@ const deserializeAws_json1_1AssignTapePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1917,10 +1921,12 @@ const deserializeAws_json1_1AssignTapePoolCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1952,8 +1958,7 @@ const deserializeAws_json1_1AssociateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -1963,10 +1968,12 @@ const deserializeAws_json1_1AssociateFileSystemCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1998,8 +2005,7 @@ const deserializeAws_json1_1AttachVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2009,10 +2015,12 @@ const deserializeAws_json1_1AttachVolumeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2044,8 +2052,7 @@ const deserializeAws_json1_1CancelArchivalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2055,10 +2062,12 @@ const deserializeAws_json1_1CancelArchivalCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2090,8 +2099,7 @@ const deserializeAws_json1_1CancelRetrievalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2101,10 +2109,12 @@ const deserializeAws_json1_1CancelRetrievalCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2136,8 +2146,7 @@ const deserializeAws_json1_1CreateCachediSCSIVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2147,10 +2156,12 @@ const deserializeAws_json1_1CreateCachediSCSIVolumeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2182,8 +2193,7 @@ const deserializeAws_json1_1CreateNFSFileShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2193,10 +2203,12 @@ const deserializeAws_json1_1CreateNFSFileShareCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2228,8 +2240,7 @@ const deserializeAws_json1_1CreateSMBFileShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2239,10 +2250,12 @@ const deserializeAws_json1_1CreateSMBFileShareCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2274,8 +2287,7 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2288,10 +2300,12 @@ const deserializeAws_json1_1CreateSnapshotCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2323,8 +2337,7 @@ const deserializeAws_json1_1CreateSnapshotFromVolumeRecoveryPointCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2337,10 +2350,12 @@ const deserializeAws_json1_1CreateSnapshotFromVolumeRecoveryPointCommandError = throw await deserializeAws_json1_1ServiceUnavailableErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2372,8 +2387,7 @@ const deserializeAws_json1_1CreateStorediSCSIVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2383,10 +2397,12 @@ const deserializeAws_json1_1CreateStorediSCSIVolumeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2418,8 +2434,7 @@ const deserializeAws_json1_1CreateTapePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2429,10 +2444,12 @@ const deserializeAws_json1_1CreateTapePoolCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2464,8 +2481,7 @@ const deserializeAws_json1_1CreateTapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2475,10 +2491,12 @@ const deserializeAws_json1_1CreateTapesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2510,8 +2528,7 @@ const deserializeAws_json1_1CreateTapeWithBarcodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2521,10 +2538,12 @@ const deserializeAws_json1_1CreateTapeWithBarcodeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2556,8 +2575,7 @@ const deserializeAws_json1_1DeleteAutomaticTapeCreationPolicyCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2567,10 +2585,12 @@ const deserializeAws_json1_1DeleteAutomaticTapeCreationPolicyCommandError = asyn throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2602,8 +2622,7 @@ const deserializeAws_json1_1DeleteBandwidthRateLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2613,10 +2632,12 @@ const deserializeAws_json1_1DeleteBandwidthRateLimitCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2648,8 +2669,7 @@ const deserializeAws_json1_1DeleteChapCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2659,10 +2679,12 @@ const deserializeAws_json1_1DeleteChapCredentialsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2694,8 +2716,7 @@ const deserializeAws_json1_1DeleteFileShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2705,10 +2726,12 @@ const deserializeAws_json1_1DeleteFileShareCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2740,8 +2763,7 @@ const deserializeAws_json1_1DeleteGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2751,10 +2773,12 @@ const deserializeAws_json1_1DeleteGatewayCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2786,8 +2810,7 @@ const deserializeAws_json1_1DeleteSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2797,10 +2820,12 @@ const deserializeAws_json1_1DeleteSnapshotScheduleCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2832,8 +2857,7 @@ const deserializeAws_json1_1DeleteTapeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2843,10 +2867,12 @@ const deserializeAws_json1_1DeleteTapeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2878,8 +2904,7 @@ const deserializeAws_json1_1DeleteTapeArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2889,10 +2914,12 @@ const deserializeAws_json1_1DeleteTapeArchiveCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2924,8 +2951,7 @@ const deserializeAws_json1_1DeleteTapePoolCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2935,10 +2961,12 @@ const deserializeAws_json1_1DeleteTapePoolCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2970,8 +2998,7 @@ const deserializeAws_json1_1DeleteVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -2981,10 +3008,12 @@ const deserializeAws_json1_1DeleteVolumeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3016,8 +3045,7 @@ const deserializeAws_json1_1DescribeAvailabilityMonitorTestCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3027,10 +3055,12 @@ const deserializeAws_json1_1DescribeAvailabilityMonitorTestCommandError = async throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3062,8 +3092,7 @@ const deserializeAws_json1_1DescribeBandwidthRateLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3073,10 +3102,12 @@ const deserializeAws_json1_1DescribeBandwidthRateLimitCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3108,8 +3139,7 @@ const deserializeAws_json1_1DescribeBandwidthRateLimitScheduleCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3119,10 +3149,12 @@ const deserializeAws_json1_1DescribeBandwidthRateLimitScheduleCommandError = asy throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3154,8 +3186,7 @@ const deserializeAws_json1_1DescribeCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3165,10 +3196,12 @@ const deserializeAws_json1_1DescribeCacheCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3200,8 +3233,7 @@ const deserializeAws_json1_1DescribeCachediSCSIVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3211,10 +3243,12 @@ const deserializeAws_json1_1DescribeCachediSCSIVolumesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3246,8 +3280,7 @@ const deserializeAws_json1_1DescribeChapCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3257,10 +3290,12 @@ const deserializeAws_json1_1DescribeChapCredentialsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3292,8 +3327,7 @@ const deserializeAws_json1_1DescribeFileSystemAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3303,10 +3337,12 @@ const deserializeAws_json1_1DescribeFileSystemAssociationsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3338,8 +3374,7 @@ const deserializeAws_json1_1DescribeGatewayInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3349,10 +3384,12 @@ const deserializeAws_json1_1DescribeGatewayInformationCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3384,8 +3421,7 @@ const deserializeAws_json1_1DescribeMaintenanceStartTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3395,10 +3431,12 @@ const deserializeAws_json1_1DescribeMaintenanceStartTimeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3430,8 +3468,7 @@ const deserializeAws_json1_1DescribeNFSFileSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3441,10 +3478,12 @@ const deserializeAws_json1_1DescribeNFSFileSharesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3476,8 +3515,7 @@ const deserializeAws_json1_1DescribeSMBFileSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3487,10 +3525,12 @@ const deserializeAws_json1_1DescribeSMBFileSharesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3522,8 +3562,7 @@ const deserializeAws_json1_1DescribeSMBSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3533,10 +3572,12 @@ const deserializeAws_json1_1DescribeSMBSettingsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3568,8 +3609,7 @@ const deserializeAws_json1_1DescribeSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3579,10 +3619,12 @@ const deserializeAws_json1_1DescribeSnapshotScheduleCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3614,8 +3656,7 @@ const deserializeAws_json1_1DescribeStorediSCSIVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3625,10 +3666,12 @@ const deserializeAws_json1_1DescribeStorediSCSIVolumesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3660,8 +3703,7 @@ const deserializeAws_json1_1DescribeTapeArchivesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3671,10 +3713,12 @@ const deserializeAws_json1_1DescribeTapeArchivesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3706,8 +3750,7 @@ const deserializeAws_json1_1DescribeTapeRecoveryPointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3717,10 +3760,12 @@ const deserializeAws_json1_1DescribeTapeRecoveryPointsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3752,8 +3797,7 @@ const deserializeAws_json1_1DescribeTapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3763,10 +3807,12 @@ const deserializeAws_json1_1DescribeTapesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3798,8 +3844,7 @@ const deserializeAws_json1_1DescribeUploadBufferCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3809,10 +3854,12 @@ const deserializeAws_json1_1DescribeUploadBufferCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3844,8 +3891,7 @@ const deserializeAws_json1_1DescribeVTLDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3855,10 +3901,12 @@ const deserializeAws_json1_1DescribeVTLDevicesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3890,8 +3938,7 @@ const deserializeAws_json1_1DescribeWorkingStorageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3901,10 +3948,12 @@ const deserializeAws_json1_1DescribeWorkingStorageCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3936,8 +3985,7 @@ const deserializeAws_json1_1DetachVolumeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3947,10 +3995,12 @@ const deserializeAws_json1_1DetachVolumeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3982,8 +4032,7 @@ const deserializeAws_json1_1DisableGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -3993,10 +4042,12 @@ const deserializeAws_json1_1DisableGatewayCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4028,8 +4079,7 @@ const deserializeAws_json1_1DisassociateFileSystemCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4039,10 +4089,12 @@ const deserializeAws_json1_1DisassociateFileSystemCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4074,8 +4126,7 @@ const deserializeAws_json1_1JoinDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4085,10 +4136,12 @@ const deserializeAws_json1_1JoinDomainCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4120,8 +4173,7 @@ const deserializeAws_json1_1ListAutomaticTapeCreationPoliciesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4131,10 +4183,12 @@ const deserializeAws_json1_1ListAutomaticTapeCreationPoliciesCommandError = asyn throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4166,8 +4220,7 @@ const deserializeAws_json1_1ListFileSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4177,10 +4230,12 @@ const deserializeAws_json1_1ListFileSharesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4212,8 +4267,7 @@ const deserializeAws_json1_1ListFileSystemAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4223,10 +4277,12 @@ const deserializeAws_json1_1ListFileSystemAssociationsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4258,8 +4314,7 @@ const deserializeAws_json1_1ListGatewaysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4269,10 +4324,12 @@ const deserializeAws_json1_1ListGatewaysCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4304,8 +4361,7 @@ const deserializeAws_json1_1ListLocalDisksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4315,10 +4371,12 @@ const deserializeAws_json1_1ListLocalDisksCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4350,8 +4408,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4361,10 +4418,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4396,8 +4455,7 @@ const deserializeAws_json1_1ListTapePoolsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4407,10 +4465,12 @@ const deserializeAws_json1_1ListTapePoolsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4442,8 +4502,7 @@ const deserializeAws_json1_1ListTapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4453,10 +4512,12 @@ const deserializeAws_json1_1ListTapesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4488,8 +4549,7 @@ const deserializeAws_json1_1ListVolumeInitiatorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4499,10 +4559,12 @@ const deserializeAws_json1_1ListVolumeInitiatorsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4534,8 +4596,7 @@ const deserializeAws_json1_1ListVolumeRecoveryPointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4545,10 +4606,12 @@ const deserializeAws_json1_1ListVolumeRecoveryPointsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4580,8 +4643,7 @@ const deserializeAws_json1_1ListVolumesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4591,10 +4653,12 @@ const deserializeAws_json1_1ListVolumesCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4626,8 +4690,7 @@ const deserializeAws_json1_1NotifyWhenUploadedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4637,10 +4700,12 @@ const deserializeAws_json1_1NotifyWhenUploadedCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4672,8 +4737,7 @@ const deserializeAws_json1_1RefreshCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4683,10 +4747,12 @@ const deserializeAws_json1_1RefreshCacheCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4718,8 +4784,7 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4729,10 +4794,12 @@ const deserializeAws_json1_1RemoveTagsFromResourceCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4764,8 +4831,7 @@ const deserializeAws_json1_1ResetCacheCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4775,10 +4841,12 @@ const deserializeAws_json1_1ResetCacheCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4810,8 +4878,7 @@ const deserializeAws_json1_1RetrieveTapeArchiveCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4821,10 +4888,12 @@ const deserializeAws_json1_1RetrieveTapeArchiveCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4856,8 +4925,7 @@ const deserializeAws_json1_1RetrieveTapeRecoveryPointCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4867,10 +4935,12 @@ const deserializeAws_json1_1RetrieveTapeRecoveryPointCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4902,8 +4972,7 @@ const deserializeAws_json1_1SetLocalConsolePasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4913,10 +4982,12 @@ const deserializeAws_json1_1SetLocalConsolePasswordCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4948,8 +5019,7 @@ const deserializeAws_json1_1SetSMBGuestPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -4959,10 +5029,12 @@ const deserializeAws_json1_1SetSMBGuestPasswordCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4994,8 +5066,7 @@ const deserializeAws_json1_1ShutdownGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5005,10 +5076,12 @@ const deserializeAws_json1_1ShutdownGatewayCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5040,8 +5113,7 @@ const deserializeAws_json1_1StartAvailabilityMonitorTestCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5051,10 +5123,12 @@ const deserializeAws_json1_1StartAvailabilityMonitorTestCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5086,8 +5160,7 @@ const deserializeAws_json1_1StartGatewayCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5097,10 +5170,12 @@ const deserializeAws_json1_1StartGatewayCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5132,8 +5207,7 @@ const deserializeAws_json1_1UpdateAutomaticTapeCreationPolicyCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5143,10 +5217,12 @@ const deserializeAws_json1_1UpdateAutomaticTapeCreationPolicyCommandError = asyn throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5178,8 +5254,7 @@ const deserializeAws_json1_1UpdateBandwidthRateLimitCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5189,10 +5264,12 @@ const deserializeAws_json1_1UpdateBandwidthRateLimitCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5224,8 +5301,7 @@ const deserializeAws_json1_1UpdateBandwidthRateLimitScheduleCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5235,10 +5311,12 @@ const deserializeAws_json1_1UpdateBandwidthRateLimitScheduleCommandError = async throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5270,8 +5348,7 @@ const deserializeAws_json1_1UpdateChapCredentialsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5281,10 +5358,12 @@ const deserializeAws_json1_1UpdateChapCredentialsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5316,8 +5395,7 @@ const deserializeAws_json1_1UpdateFileSystemAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5327,10 +5405,12 @@ const deserializeAws_json1_1UpdateFileSystemAssociationCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5362,8 +5442,7 @@ const deserializeAws_json1_1UpdateGatewayInformationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5373,10 +5452,12 @@ const deserializeAws_json1_1UpdateGatewayInformationCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5408,8 +5489,7 @@ const deserializeAws_json1_1UpdateGatewaySoftwareNowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5419,10 +5499,12 @@ const deserializeAws_json1_1UpdateGatewaySoftwareNowCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5454,8 +5536,7 @@ const deserializeAws_json1_1UpdateMaintenanceStartTimeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5465,10 +5546,12 @@ const deserializeAws_json1_1UpdateMaintenanceStartTimeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5500,8 +5583,7 @@ const deserializeAws_json1_1UpdateNFSFileShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5511,10 +5593,12 @@ const deserializeAws_json1_1UpdateNFSFileShareCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5546,8 +5630,7 @@ const deserializeAws_json1_1UpdateSMBFileShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5557,10 +5640,12 @@ const deserializeAws_json1_1UpdateSMBFileShareCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5592,8 +5677,7 @@ const deserializeAws_json1_1UpdateSMBFileShareVisibilityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5603,10 +5687,12 @@ const deserializeAws_json1_1UpdateSMBFileShareVisibilityCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5638,8 +5724,7 @@ const deserializeAws_json1_1UpdateSMBLocalGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5649,10 +5734,12 @@ const deserializeAws_json1_1UpdateSMBLocalGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5684,8 +5771,7 @@ const deserializeAws_json1_1UpdateSMBSecurityStrategyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5695,10 +5781,12 @@ const deserializeAws_json1_1UpdateSMBSecurityStrategyCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5730,8 +5818,7 @@ const deserializeAws_json1_1UpdateSnapshotScheduleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5741,10 +5828,12 @@ const deserializeAws_json1_1UpdateSnapshotScheduleCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5776,8 +5865,7 @@ const deserializeAws_json1_1UpdateVTLDeviceTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.storagegateway#InternalServerError": @@ -5787,10 +5875,12 @@ const deserializeAws_json1_1UpdateVTLDeviceTypeCommandError = async ( throw await deserializeAws_json1_1InvalidGatewayRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9085,7 +9175,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9111,6 +9201,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-sts/src/protocols/Aws_query.ts b/clients/client-sts/src/protocols/Aws_query.ts index 058f16aa4b75f..60f2a01cb99b4 100644 --- a/clients/client-sts/src/protocols/Aws_query.ts +++ b/clients/client-sts/src/protocols/Aws_query.ts @@ -219,8 +219,7 @@ const deserializeAws_queryAssumeRoleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredTokenException": case "com.amazonaws.sts#ExpiredTokenException": @@ -236,10 +235,12 @@ const deserializeAws_queryAssumeRoleCommandError = async ( throw await deserializeAws_queryRegionDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -271,8 +272,7 @@ const deserializeAws_queryAssumeRoleWithSAMLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredTokenException": case "com.amazonaws.sts#ExpiredTokenException": @@ -294,10 +294,12 @@ const deserializeAws_queryAssumeRoleWithSAMLCommandError = async ( throw await deserializeAws_queryRegionDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -329,8 +331,7 @@ const deserializeAws_queryAssumeRoleWithWebIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ExpiredTokenException": case "com.amazonaws.sts#ExpiredTokenException": @@ -355,10 +356,12 @@ const deserializeAws_queryAssumeRoleWithWebIdentityCommandError = async ( throw await deserializeAws_queryRegionDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -390,18 +393,19 @@ const deserializeAws_queryDecodeAuthorizationMessageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidAuthorizationMessageException": case "com.amazonaws.sts#InvalidAuthorizationMessageException": throw await deserializeAws_queryInvalidAuthorizationMessageExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -433,15 +437,16 @@ const deserializeAws_queryGetAccessKeyInfoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -473,15 +478,16 @@ const deserializeAws_queryGetCallerIdentityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -513,8 +519,7 @@ const deserializeAws_queryGetFederationTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "MalformedPolicyDocumentException": case "com.amazonaws.sts#MalformedPolicyDocumentException": @@ -527,10 +532,12 @@ const deserializeAws_queryGetFederationTokenCommandError = async ( throw await deserializeAws_queryRegionDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -562,18 +569,19 @@ const deserializeAws_queryGetSessionTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "RegionDisabledException": case "com.amazonaws.sts#RegionDisabledException": throw await deserializeAws_queryRegionDisabledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1330,12 +1338,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/clients/client-support/src/protocols/Aws_json1_1.ts b/clients/client-support/src/protocols/Aws_json1_1.ts index 6343779f9d407..2c02dc2a1d261 100644 --- a/clients/client-support/src/protocols/Aws_json1_1.ts +++ b/clients/client-support/src/protocols/Aws_json1_1.ts @@ -320,8 +320,7 @@ const deserializeAws_json1_1AddAttachmentsToSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AttachmentLimitExceeded": case "com.amazonaws.support#AttachmentLimitExceeded": @@ -340,10 +339,12 @@ const deserializeAws_json1_1AddAttachmentsToSetCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -375,8 +376,7 @@ const deserializeAws_json1_1AddCommunicationToCaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AttachmentSetExpired": case "com.amazonaws.support#AttachmentSetExpired": @@ -392,10 +392,12 @@ const deserializeAws_json1_1AddCommunicationToCaseCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -427,8 +429,7 @@ const deserializeAws_json1_1CreateCaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AttachmentSetExpired": case "com.amazonaws.support#AttachmentSetExpired": @@ -444,10 +445,12 @@ const deserializeAws_json1_1CreateCaseCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -479,8 +482,7 @@ const deserializeAws_json1_1DescribeAttachmentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AttachmentIdNotFound": case "com.amazonaws.support#AttachmentIdNotFound": @@ -493,10 +495,12 @@ const deserializeAws_json1_1DescribeAttachmentCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -528,8 +532,7 @@ const deserializeAws_json1_1DescribeCasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CaseIdNotFound": case "com.amazonaws.support#CaseIdNotFound": @@ -539,10 +542,12 @@ const deserializeAws_json1_1DescribeCasesCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -574,8 +579,7 @@ const deserializeAws_json1_1DescribeCommunicationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CaseIdNotFound": case "com.amazonaws.support#CaseIdNotFound": @@ -585,10 +589,12 @@ const deserializeAws_json1_1DescribeCommunicationsCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -620,18 +626,19 @@ const deserializeAws_json1_1DescribeServicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -663,18 +670,19 @@ const deserializeAws_json1_1DescribeSeverityLevelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -706,18 +714,19 @@ const deserializeAws_json1_1DescribeTrustedAdvisorCheckRefreshStatusesCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -749,18 +758,19 @@ const deserializeAws_json1_1DescribeTrustedAdvisorCheckResultCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -792,18 +802,19 @@ const deserializeAws_json1_1DescribeTrustedAdvisorChecksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -835,18 +846,19 @@ const deserializeAws_json1_1DescribeTrustedAdvisorCheckSummariesCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -878,18 +890,19 @@ const deserializeAws_json1_1RefreshTrustedAdvisorCheckCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerError": case "com.amazonaws.support#InternalServerError": throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -921,8 +934,7 @@ const deserializeAws_json1_1ResolveCaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CaseIdNotFound": case "com.amazonaws.support#CaseIdNotFound": @@ -932,10 +944,12 @@ const deserializeAws_json1_1ResolveCaseCommandError = async ( throw await deserializeAws_json1_1InternalServerErrorResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1919,7 +1933,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1945,6 +1959,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-swf/src/protocols/Aws_json1_0.ts b/clients/client-swf/src/protocols/Aws_json1_0.ts index 1fdcb21039e87..e2e1946e8adf5 100644 --- a/clients/client-swf/src/protocols/Aws_json1_0.ts +++ b/clients/client-swf/src/protocols/Aws_json1_0.ts @@ -800,8 +800,7 @@ const deserializeAws_json1_0CountClosedWorkflowExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -811,10 +810,12 @@ const deserializeAws_json1_0CountClosedWorkflowExecutionsCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -846,8 +847,7 @@ const deserializeAws_json1_0CountOpenWorkflowExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -857,10 +857,12 @@ const deserializeAws_json1_0CountOpenWorkflowExecutionsCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -892,8 +894,7 @@ const deserializeAws_json1_0CountPendingActivityTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -903,10 +904,12 @@ const deserializeAws_json1_0CountPendingActivityTasksCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -938,8 +941,7 @@ const deserializeAws_json1_0CountPendingDecisionTasksCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -949,10 +951,12 @@ const deserializeAws_json1_0CountPendingDecisionTasksCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -981,8 +985,7 @@ const deserializeAws_json1_0DeprecateActivityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -995,10 +998,12 @@ const deserializeAws_json1_0DeprecateActivityTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1027,8 +1032,7 @@ const deserializeAws_json1_0DeprecateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainDeprecatedFault": case "com.amazonaws.swf#DomainDeprecatedFault": @@ -1041,10 +1045,12 @@ const deserializeAws_json1_0DeprecateDomainCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1073,8 +1079,7 @@ const deserializeAws_json1_0DeprecateWorkflowTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1087,10 +1092,12 @@ const deserializeAws_json1_0DeprecateWorkflowTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1122,8 +1129,7 @@ const deserializeAws_json1_0DescribeActivityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1133,10 +1139,12 @@ const deserializeAws_json1_0DescribeActivityTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1168,8 +1176,7 @@ const deserializeAws_json1_0DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1179,10 +1186,12 @@ const deserializeAws_json1_0DescribeDomainCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1214,8 +1223,7 @@ const deserializeAws_json1_0DescribeWorkflowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1225,10 +1233,12 @@ const deserializeAws_json1_0DescribeWorkflowExecutionCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1260,8 +1270,7 @@ const deserializeAws_json1_0DescribeWorkflowTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1271,10 +1280,12 @@ const deserializeAws_json1_0DescribeWorkflowTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1306,8 +1317,7 @@ const deserializeAws_json1_0GetWorkflowExecutionHistoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1317,10 +1327,12 @@ const deserializeAws_json1_0GetWorkflowExecutionHistoryCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1352,8 +1364,7 @@ const deserializeAws_json1_0ListActivityTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1363,10 +1374,12 @@ const deserializeAws_json1_0ListActivityTypesCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1398,8 +1411,7 @@ const deserializeAws_json1_0ListClosedWorkflowExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1409,10 +1421,12 @@ const deserializeAws_json1_0ListClosedWorkflowExecutionsCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1444,18 +1458,19 @@ const deserializeAws_json1_0ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": throw await deserializeAws_json1_0OperationNotPermittedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1487,8 +1502,7 @@ const deserializeAws_json1_0ListOpenWorkflowExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1498,10 +1512,12 @@ const deserializeAws_json1_0ListOpenWorkflowExecutionsCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1533,8 +1549,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -1547,10 +1562,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1599,7 @@ const deserializeAws_json1_0ListWorkflowTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1593,10 +1609,12 @@ const deserializeAws_json1_0ListWorkflowTypesCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1628,8 +1646,7 @@ const deserializeAws_json1_0PollForActivityTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -1642,10 +1659,12 @@ const deserializeAws_json1_0PollForActivityTaskCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1677,8 +1696,7 @@ const deserializeAws_json1_0PollForDecisionTaskCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -1691,10 +1709,12 @@ const deserializeAws_json1_0PollForDecisionTaskCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1726,8 +1746,7 @@ const deserializeAws_json1_0RecordActivityTaskHeartbeatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1737,10 +1756,12 @@ const deserializeAws_json1_0RecordActivityTaskHeartbeatCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1769,8 +1790,7 @@ const deserializeAws_json1_0RegisterActivityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -1786,10 +1806,12 @@ const deserializeAws_json1_0RegisterActivityTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1818,8 +1840,7 @@ const deserializeAws_json1_0RegisterDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainAlreadyExistsFault": case "com.amazonaws.swf#DomainAlreadyExistsFault": @@ -1835,10 +1856,12 @@ const deserializeAws_json1_0RegisterDomainCommandError = async ( throw await deserializeAws_json1_0TooManyTagsFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1867,8 +1890,7 @@ const deserializeAws_json1_0RegisterWorkflowTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -1884,10 +1906,12 @@ const deserializeAws_json1_0RegisterWorkflowTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1916,8 +1940,7 @@ const deserializeAws_json1_0RequestCancelWorkflowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1927,10 +1950,12 @@ const deserializeAws_json1_0RequestCancelWorkflowExecutionCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1959,8 +1984,7 @@ const deserializeAws_json1_0RespondActivityTaskCanceledCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -1970,10 +1994,12 @@ const deserializeAws_json1_0RespondActivityTaskCanceledCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2002,8 +2028,7 @@ const deserializeAws_json1_0RespondActivityTaskCompletedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2013,10 +2038,12 @@ const deserializeAws_json1_0RespondActivityTaskCompletedCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2072,7 @@ const deserializeAws_json1_0RespondActivityTaskFailedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2056,10 +2082,12 @@ const deserializeAws_json1_0RespondActivityTaskFailedCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2088,8 +2116,7 @@ const deserializeAws_json1_0RespondDecisionTaskCompletedCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2099,10 +2126,12 @@ const deserializeAws_json1_0RespondDecisionTaskCompletedCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2131,8 +2160,7 @@ const deserializeAws_json1_0SignalWorkflowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2142,10 +2170,12 @@ const deserializeAws_json1_0SignalWorkflowExecutionCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2177,8 +2207,7 @@ const deserializeAws_json1_0StartWorkflowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DefaultUndefinedFault": case "com.amazonaws.swf#DefaultUndefinedFault": @@ -2200,10 +2229,12 @@ const deserializeAws_json1_0StartWorkflowExecutionCommandError = async ( throw await deserializeAws_json1_0WorkflowExecutionAlreadyStartedFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2232,8 +2263,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -2249,10 +2279,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2281,8 +2313,7 @@ const deserializeAws_json1_0TerminateWorkflowExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2292,10 +2323,12 @@ const deserializeAws_json1_0TerminateWorkflowExecutionCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2324,8 +2357,7 @@ const deserializeAws_json1_0UndeprecateActivityTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2338,10 +2370,12 @@ const deserializeAws_json1_0UndeprecateActivityTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2370,8 +2404,7 @@ const deserializeAws_json1_0UndeprecateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DomainAlreadyExistsFault": case "com.amazonaws.swf#DomainAlreadyExistsFault": @@ -2384,10 +2417,12 @@ const deserializeAws_json1_0UndeprecateDomainCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2416,8 +2451,7 @@ const deserializeAws_json1_0UndeprecateWorkflowTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OperationNotPermittedFault": case "com.amazonaws.swf#OperationNotPermittedFault": @@ -2430,10 +2464,12 @@ const deserializeAws_json1_0UndeprecateWorkflowTypeCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2462,8 +2498,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "LimitExceededFault": case "com.amazonaws.swf#LimitExceededFault": @@ -2476,10 +2511,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0UnknownResourceFaultResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5238,7 +5275,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5264,6 +5301,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-synthetics/src/protocols/Aws_restJson1.ts b/clients/client-synthetics/src/protocols/Aws_restJson1.ts index a9e98bc263620..70179ed10a31b 100644 --- a/clients/client-synthetics/src/protocols/Aws_restJson1.ts +++ b/clients/client-synthetics/src/protocols/Aws_restJson1.ts @@ -533,8 +533,7 @@ const deserializeAws_restJson1CreateCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -547,10 +546,12 @@ const deserializeAws_restJson1CreateCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -579,8 +580,7 @@ const deserializeAws_restJson1DeleteCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.synthetics#ConflictException": @@ -596,10 +596,12 @@ const deserializeAws_restJson1DeleteCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -636,8 +638,7 @@ const deserializeAws_restJson1DescribeCanariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -647,10 +648,12 @@ const deserializeAws_restJson1DescribeCanariesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -687,8 +690,7 @@ const deserializeAws_restJson1DescribeCanariesLastRunCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -698,10 +700,12 @@ const deserializeAws_restJson1DescribeCanariesLastRunCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -738,8 +742,7 @@ const deserializeAws_restJson1DescribeRuntimeVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -749,10 +752,12 @@ const deserializeAws_restJson1DescribeRuntimeVersionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -785,8 +790,7 @@ const deserializeAws_restJson1GetCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -796,10 +800,12 @@ const deserializeAws_restJson1GetCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -836,8 +842,7 @@ const deserializeAws_restJson1GetCanaryRunsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -850,10 +855,12 @@ const deserializeAws_restJson1GetCanaryRunsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -886,8 +893,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -900,10 +906,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -932,8 +940,7 @@ const deserializeAws_restJson1StartCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.synthetics#ConflictException": @@ -949,10 +956,12 @@ const deserializeAws_restJson1StartCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -981,8 +990,7 @@ const deserializeAws_restJson1StopCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.synthetics#ConflictException": @@ -998,10 +1006,12 @@ const deserializeAws_restJson1StopCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1030,8 +1040,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -1044,10 +1053,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1076,8 +1087,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.synthetics#InternalServerException": @@ -1090,10 +1100,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1122,8 +1134,7 @@ const deserializeAws_restJson1UpdateCanaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.synthetics#ConflictException": @@ -1142,10 +1153,12 @@ const deserializeAws_restJson1UpdateCanaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1759,7 +1772,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1785,6 +1798,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-textract/src/protocols/Aws_json1_1.ts b/clients/client-textract/src/protocols/Aws_json1_1.ts index aa80c2b8591dc..e353343eb158a 100644 --- a/clients/client-textract/src/protocols/Aws_json1_1.ts +++ b/clients/client-textract/src/protocols/Aws_json1_1.ts @@ -263,8 +263,7 @@ const deserializeAws_json1_1AnalyzeDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -298,10 +297,12 @@ const deserializeAws_json1_1AnalyzeDocumentCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -333,8 +334,7 @@ const deserializeAws_json1_1AnalyzeExpenseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -365,10 +365,12 @@ const deserializeAws_json1_1AnalyzeExpenseCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -400,8 +402,7 @@ const deserializeAws_json1_1AnalyzeIDCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -432,10 +433,12 @@ const deserializeAws_json1_1AnalyzeIDCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -467,8 +470,7 @@ const deserializeAws_json1_1DetectDocumentTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -499,10 +501,12 @@ const deserializeAws_json1_1DetectDocumentTextCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -534,8 +538,7 @@ const deserializeAws_json1_1GetDocumentAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -563,10 +566,12 @@ const deserializeAws_json1_1GetDocumentAnalysisCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -598,8 +603,7 @@ const deserializeAws_json1_1GetDocumentTextDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -627,10 +631,12 @@ const deserializeAws_json1_1GetDocumentTextDetectionCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -662,8 +668,7 @@ const deserializeAws_json1_1GetExpenseAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -691,10 +696,12 @@ const deserializeAws_json1_1GetExpenseAnalysisCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -726,8 +733,7 @@ const deserializeAws_json1_1StartDocumentAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -767,10 +773,12 @@ const deserializeAws_json1_1StartDocumentAnalysisCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -802,8 +810,7 @@ const deserializeAws_json1_1StartDocumentTextDetectionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -843,10 +850,12 @@ const deserializeAws_json1_1StartDocumentTextDetectionCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -878,8 +887,7 @@ const deserializeAws_json1_1StartExpenseAnalysisCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.textract#AccessDeniedException": @@ -919,10 +927,12 @@ const deserializeAws_json1_1StartExpenseAnalysisCommandError = async ( throw await deserializeAws_json1_1UnsupportedDocumentExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2138,7 +2148,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2164,6 +2174,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-timestream-query/src/protocols/Aws_json1_0.ts b/clients/client-timestream-query/src/protocols/Aws_json1_0.ts index 8e53c381ebdf7..e06d6a892513b 100644 --- a/clients/client-timestream-query/src/protocols/Aws_json1_0.ts +++ b/clients/client-timestream-query/src/protocols/Aws_json1_0.ts @@ -312,8 +312,7 @@ const deserializeAws_json1_0CancelQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -332,10 +331,12 @@ const deserializeAws_json1_0CancelQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -367,8 +368,7 @@ const deserializeAws_json1_0CreateScheduledQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -393,10 +393,12 @@ const deserializeAws_json1_0CreateScheduledQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -425,8 +427,7 @@ const deserializeAws_json1_0DeleteScheduledQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -448,10 +449,12 @@ const deserializeAws_json1_0DeleteScheduledQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -483,8 +486,7 @@ const deserializeAws_json1_0DescribeEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.timestreamquery#InternalServerException": @@ -497,10 +499,12 @@ const deserializeAws_json1_0DescribeEndpointsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -532,8 +536,7 @@ const deserializeAws_json1_0DescribeScheduledQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -555,10 +558,12 @@ const deserializeAws_json1_0DescribeScheduledQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -587,8 +592,7 @@ const deserializeAws_json1_0ExecuteScheduledQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -610,10 +614,12 @@ const deserializeAws_json1_0ExecuteScheduledQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -645,8 +651,7 @@ const deserializeAws_json1_0ListScheduledQueriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -665,10 +670,12 @@ const deserializeAws_json1_0ListScheduledQueriesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -700,8 +707,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamquery#InvalidEndpointException": @@ -717,10 +723,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -752,8 +760,7 @@ const deserializeAws_json1_0PrepareQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -772,10 +779,12 @@ const deserializeAws_json1_0PrepareQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -807,8 +816,7 @@ const deserializeAws_json1_0QueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -833,10 +841,12 @@ const deserializeAws_json1_0QueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -868,8 +878,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamquery#InvalidEndpointException": @@ -888,10 +897,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -923,8 +934,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamquery#InvalidEndpointException": @@ -940,10 +950,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -972,8 +984,7 @@ const deserializeAws_json1_0UpdateScheduledQueryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamquery#AccessDeniedException": @@ -995,10 +1006,12 @@ const deserializeAws_json1_0UpdateScheduledQueryCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2227,7 +2240,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2253,6 +2266,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-timestream-write/src/protocols/Aws_json1_0.ts b/clients/client-timestream-write/src/protocols/Aws_json1_0.ts index a14f050b61eb6..7b8660a6bb475 100644 --- a/clients/client-timestream-write/src/protocols/Aws_json1_0.ts +++ b/clients/client-timestream-write/src/protocols/Aws_json1_0.ts @@ -310,8 +310,7 @@ const deserializeAws_json1_0CreateDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -336,10 +335,12 @@ const deserializeAws_json1_0CreateDatabaseCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -371,8 +372,7 @@ const deserializeAws_json1_0CreateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -400,10 +400,12 @@ const deserializeAws_json1_0CreateTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -432,8 +434,7 @@ const deserializeAws_json1_0DeleteDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -455,10 +456,12 @@ const deserializeAws_json1_0DeleteDatabaseCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -487,8 +490,7 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -510,10 +512,12 @@ const deserializeAws_json1_0DeleteTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -545,8 +549,7 @@ const deserializeAws_json1_0DescribeDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -568,10 +571,12 @@ const deserializeAws_json1_0DescribeDatabaseCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -603,8 +608,7 @@ const deserializeAws_json1_0DescribeEndpointsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.timestreamwrite#InternalServerException": @@ -617,10 +621,12 @@ const deserializeAws_json1_0DescribeEndpointsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -652,8 +658,7 @@ const deserializeAws_json1_0DescribeTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -675,10 +680,12 @@ const deserializeAws_json1_0DescribeTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -710,8 +717,7 @@ const deserializeAws_json1_0ListDatabasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -730,10 +736,12 @@ const deserializeAws_json1_0ListDatabasesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -765,8 +773,7 @@ const deserializeAws_json1_0ListTablesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -788,10 +795,12 @@ const deserializeAws_json1_0ListTablesCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -823,8 +832,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamwrite#InvalidEndpointException": @@ -840,10 +848,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -875,8 +885,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamwrite#InvalidEndpointException": @@ -895,10 +904,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -930,8 +941,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidEndpointException": case "com.amazonaws.timestreamwrite#InvalidEndpointException": @@ -950,10 +960,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -985,8 +997,7 @@ const deserializeAws_json1_0UpdateDatabaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -1011,10 +1022,12 @@ const deserializeAws_json1_0UpdateDatabaseCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1046,8 +1059,7 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -1069,10 +1081,12 @@ const deserializeAws_json1_0UpdateTableCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1104,8 +1118,7 @@ const deserializeAws_json1_0WriteRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.timestreamwrite#AccessDeniedException": @@ -1130,10 +1143,12 @@ const deserializeAws_json1_0WriteRecordsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1962,7 +1977,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1988,6 +2003,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts b/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts index 85a09cdd36749..dd30dfb42e073 100644 --- a/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts +++ b/clients/client-transcribe-streaming/src/protocols/Aws_restJson1.ts @@ -270,8 +270,7 @@ const deserializeAws_restJson1StartMedicalStreamTranscriptionCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribestreaming#BadRequestException": @@ -290,10 +289,12 @@ const deserializeAws_restJson1StartMedicalStreamTranscriptionCommandError = asyn throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -430,8 +431,7 @@ const deserializeAws_restJson1StartStreamTranscriptionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribestreaming#BadRequestException": @@ -450,10 +450,12 @@ const deserializeAws_restJson1StartStreamTranscriptionCommandError = async ( throw await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1162,7 +1164,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1188,6 +1190,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-transcribe/src/protocols/Aws_json1_1.ts b/clients/client-transcribe/src/protocols/Aws_json1_1.ts index 50a5a0c23bb00..d08506139ac84 100644 --- a/clients/client-transcribe/src/protocols/Aws_json1_1.ts +++ b/clients/client-transcribe/src/protocols/Aws_json1_1.ts @@ -802,8 +802,7 @@ const deserializeAws_json1_1CreateCallAnalyticsCategoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -819,10 +818,12 @@ const deserializeAws_json1_1CreateCallAnalyticsCategoryCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -854,8 +855,7 @@ const deserializeAws_json1_1CreateLanguageModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -871,10 +871,12 @@ const deserializeAws_json1_1CreateLanguageModelCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -906,8 +908,7 @@ const deserializeAws_json1_1CreateMedicalVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -923,10 +924,12 @@ const deserializeAws_json1_1CreateMedicalVocabularyCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -958,8 +961,7 @@ const deserializeAws_json1_1CreateVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -975,10 +977,12 @@ const deserializeAws_json1_1CreateVocabularyCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1010,8 +1014,7 @@ const deserializeAws_json1_1CreateVocabularyFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1027,10 +1030,12 @@ const deserializeAws_json1_1CreateVocabularyFilterCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1062,8 +1067,7 @@ const deserializeAws_json1_1DeleteCallAnalyticsCategoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1079,10 +1083,12 @@ const deserializeAws_json1_1DeleteCallAnalyticsCategoryCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1114,8 +1120,7 @@ const deserializeAws_json1_1DeleteCallAnalyticsJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1128,10 +1133,12 @@ const deserializeAws_json1_1DeleteCallAnalyticsJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1160,8 +1167,7 @@ const deserializeAws_json1_1DeleteLanguageModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1174,10 +1180,12 @@ const deserializeAws_json1_1DeleteLanguageModelCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1214,7 @@ const deserializeAws_json1_1DeleteMedicalTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1220,10 +1227,12 @@ const deserializeAws_json1_1DeleteMedicalTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1252,8 +1261,7 @@ const deserializeAws_json1_1DeleteMedicalVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1269,10 +1277,12 @@ const deserializeAws_json1_1DeleteMedicalVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1301,8 +1311,7 @@ const deserializeAws_json1_1DeleteTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1315,10 +1324,12 @@ const deserializeAws_json1_1DeleteTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1347,8 +1358,7 @@ const deserializeAws_json1_1DeleteVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1364,10 +1374,12 @@ const deserializeAws_json1_1DeleteVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1396,8 +1408,7 @@ const deserializeAws_json1_1DeleteVocabularyFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1413,10 +1424,12 @@ const deserializeAws_json1_1DeleteVocabularyFilterCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1448,8 +1461,7 @@ const deserializeAws_json1_1DescribeLanguageModelCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1465,10 +1477,12 @@ const deserializeAws_json1_1DescribeLanguageModelCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1500,8 +1514,7 @@ const deserializeAws_json1_1GetCallAnalyticsCategoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1517,10 +1530,12 @@ const deserializeAws_json1_1GetCallAnalyticsCategoryCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1552,8 +1567,7 @@ const deserializeAws_json1_1GetCallAnalyticsJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1569,10 +1583,12 @@ const deserializeAws_json1_1GetCallAnalyticsJobCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1604,8 +1620,7 @@ const deserializeAws_json1_1GetMedicalTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1621,10 +1636,12 @@ const deserializeAws_json1_1GetMedicalTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1656,8 +1673,7 @@ const deserializeAws_json1_1GetMedicalVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1673,10 +1689,12 @@ const deserializeAws_json1_1GetMedicalVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1708,8 +1726,7 @@ const deserializeAws_json1_1GetTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1725,10 +1742,12 @@ const deserializeAws_json1_1GetTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1760,8 +1779,7 @@ const deserializeAws_json1_1GetVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1777,10 +1795,12 @@ const deserializeAws_json1_1GetVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1812,8 +1832,7 @@ const deserializeAws_json1_1GetVocabularyFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1829,10 +1848,12 @@ const deserializeAws_json1_1GetVocabularyFilterCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1864,8 +1885,7 @@ const deserializeAws_json1_1ListCallAnalyticsCategoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1878,10 +1898,12 @@ const deserializeAws_json1_1ListCallAnalyticsCategoriesCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1935,7 @@ const deserializeAws_json1_1ListCallAnalyticsJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1927,10 +1948,12 @@ const deserializeAws_json1_1ListCallAnalyticsJobsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1962,8 +1985,7 @@ const deserializeAws_json1_1ListLanguageModelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -1976,10 +1998,12 @@ const deserializeAws_json1_1ListLanguageModelsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2011,8 +2035,7 @@ const deserializeAws_json1_1ListMedicalTranscriptionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2025,10 +2048,12 @@ const deserializeAws_json1_1ListMedicalTranscriptionJobsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2060,8 +2085,7 @@ const deserializeAws_json1_1ListMedicalVocabulariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2074,10 +2098,12 @@ const deserializeAws_json1_1ListMedicalVocabulariesCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2109,8 +2135,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2126,10 +2151,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2161,8 +2188,7 @@ const deserializeAws_json1_1ListTranscriptionJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2175,10 +2201,12 @@ const deserializeAws_json1_1ListTranscriptionJobsCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2210,8 +2238,7 @@ const deserializeAws_json1_1ListVocabulariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2224,10 +2251,12 @@ const deserializeAws_json1_1ListVocabulariesCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2259,8 +2288,7 @@ const deserializeAws_json1_1ListVocabularyFiltersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2273,10 +2301,12 @@ const deserializeAws_json1_1ListVocabularyFiltersCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2308,8 +2338,7 @@ const deserializeAws_json1_1StartCallAnalyticsJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2325,10 +2354,12 @@ const deserializeAws_json1_1StartCallAnalyticsJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2360,8 +2391,7 @@ const deserializeAws_json1_1StartMedicalTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2377,10 +2407,12 @@ const deserializeAws_json1_1StartMedicalTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2412,8 +2444,7 @@ const deserializeAws_json1_1StartTranscriptionJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2429,10 +2460,12 @@ const deserializeAws_json1_1StartTranscriptionJobCommandError = async ( throw await deserializeAws_json1_1LimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2464,8 +2497,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2484,10 +2516,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2519,8 +2553,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2539,10 +2572,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2574,8 +2609,7 @@ const deserializeAws_json1_1UpdateCallAnalyticsCategoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2594,10 +2628,12 @@ const deserializeAws_json1_1UpdateCallAnalyticsCategoryCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2629,8 +2665,7 @@ const deserializeAws_json1_1UpdateMedicalVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2649,10 +2684,12 @@ const deserializeAws_json1_1UpdateMedicalVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2684,8 +2721,7 @@ const deserializeAws_json1_1UpdateVocabularyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2704,10 +2740,12 @@ const deserializeAws_json1_1UpdateVocabularyCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2739,8 +2777,7 @@ const deserializeAws_json1_1UpdateVocabularyFilterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "BadRequestException": case "com.amazonaws.transcribe#BadRequestException": @@ -2756,10 +2793,12 @@ const deserializeAws_json1_1UpdateVocabularyFilterCommandError = async ( throw await deserializeAws_json1_1NotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5034,7 +5073,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5060,6 +5099,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-transfer/src/protocols/Aws_json1_1.ts b/clients/client-transfer/src/protocols/Aws_json1_1.ts index efcdc0f3241a3..7527817a09a95 100644 --- a/clients/client-transfer/src/protocols/Aws_json1_1.ts +++ b/clients/client-transfer/src/protocols/Aws_json1_1.ts @@ -612,8 +612,7 @@ const deserializeAws_json1_1CreateAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -632,10 +631,12 @@ const deserializeAws_json1_1CreateAccessCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -667,8 +668,7 @@ const deserializeAws_json1_1CreateServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -693,10 +693,12 @@ const deserializeAws_json1_1CreateServerCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -728,8 +730,7 @@ const deserializeAws_json1_1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -748,10 +749,12 @@ const deserializeAws_json1_1CreateUserCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -783,8 +786,7 @@ const deserializeAws_json1_1CreateWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -806,10 +808,12 @@ const deserializeAws_json1_1CreateWorkflowCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -838,8 +842,7 @@ const deserializeAws_json1_1DeleteAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -855,10 +858,12 @@ const deserializeAws_json1_1DeleteAccessCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -887,8 +892,7 @@ const deserializeAws_json1_1DeleteServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -907,10 +911,12 @@ const deserializeAws_json1_1DeleteServerCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -939,8 +945,7 @@ const deserializeAws_json1_1DeleteSshPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -959,10 +964,12 @@ const deserializeAws_json1_1DeleteSshPublicKeyCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -991,8 +998,7 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1008,10 +1014,12 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1040,8 +1048,7 @@ const deserializeAws_json1_1DeleteWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -1060,10 +1067,12 @@ const deserializeAws_json1_1DeleteWorkflowCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1095,8 +1104,7 @@ const deserializeAws_json1_1DescribeAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1112,10 +1120,12 @@ const deserializeAws_json1_1DescribeAccessCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1147,8 +1157,7 @@ const deserializeAws_json1_1DescribeExecutionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1164,10 +1173,12 @@ const deserializeAws_json1_1DescribeExecutionCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1199,8 +1210,7 @@ const deserializeAws_json1_1DescribeSecurityPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1216,10 +1226,12 @@ const deserializeAws_json1_1DescribeSecurityPolicyCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1251,8 +1263,7 @@ const deserializeAws_json1_1DescribeServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1268,10 +1279,12 @@ const deserializeAws_json1_1DescribeServerCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1303,8 +1316,7 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1320,10 +1332,12 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1355,8 +1369,7 @@ const deserializeAws_json1_1DescribeWorkflowCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1372,10 +1385,12 @@ const deserializeAws_json1_1DescribeWorkflowCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1407,8 +1422,7 @@ const deserializeAws_json1_1ImportSshPublicKeyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1430,10 +1444,12 @@ const deserializeAws_json1_1ImportSshPublicKeyCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1465,8 +1481,7 @@ const deserializeAws_json1_1ListAccessesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1485,10 +1500,12 @@ const deserializeAws_json1_1ListAccessesCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1520,8 +1537,7 @@ const deserializeAws_json1_1ListExecutionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1540,10 +1556,12 @@ const deserializeAws_json1_1ListExecutionsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1575,8 +1593,7 @@ const deserializeAws_json1_1ListSecurityPoliciesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1592,10 +1609,12 @@ const deserializeAws_json1_1ListSecurityPoliciesCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1627,8 +1646,7 @@ const deserializeAws_json1_1ListServersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1644,10 +1662,12 @@ const deserializeAws_json1_1ListServersCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1679,8 +1699,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1696,10 +1715,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1731,8 +1752,7 @@ const deserializeAws_json1_1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1751,10 +1771,12 @@ const deserializeAws_json1_1ListUsersCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1786,8 +1808,7 @@ const deserializeAws_json1_1ListWorkflowsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1803,10 +1824,12 @@ const deserializeAws_json1_1ListWorkflowsCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1838,8 +1861,7 @@ const deserializeAws_json1_1SendWorkflowStepStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -1861,10 +1883,12 @@ const deserializeAws_json1_1SendWorkflowStepStateCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1893,8 +1917,7 @@ const deserializeAws_json1_1StartServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1913,10 +1936,12 @@ const deserializeAws_json1_1StartServerCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1945,8 +1970,7 @@ const deserializeAws_json1_1StopServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -1965,10 +1989,12 @@ const deserializeAws_json1_1StopServerCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1997,8 +2023,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -2014,10 +2039,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2049,8 +2076,7 @@ const deserializeAws_json1_1TestIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -2066,10 +2092,12 @@ const deserializeAws_json1_1TestIdentityProviderCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2098,8 +2126,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -2115,10 +2142,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2150,8 +2179,7 @@ const deserializeAws_json1_1UpdateAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -2170,10 +2198,12 @@ const deserializeAws_json1_1UpdateAccessCommandError = async ( throw await deserializeAws_json1_1ServiceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2205,8 +2235,7 @@ const deserializeAws_json1_1UpdateServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.transfer#AccessDeniedException": @@ -2234,10 +2263,12 @@ const deserializeAws_json1_1UpdateServerCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2269,8 +2300,7 @@ const deserializeAws_json1_1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServiceError": case "com.amazonaws.transfer#InternalServiceError": @@ -2289,10 +2319,12 @@ const deserializeAws_json1_1UpdateUserCommandError = async ( throw await deserializeAws_json1_1ThrottlingExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4134,7 +4166,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4160,6 +4192,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-translate/src/protocols/Aws_json1_1.ts b/clients/client-translate/src/protocols/Aws_json1_1.ts index f4b6027bf03fa..9cb8b9e718ae3 100644 --- a/clients/client-translate/src/protocols/Aws_json1_1.ts +++ b/clients/client-translate/src/protocols/Aws_json1_1.ts @@ -310,8 +310,7 @@ const deserializeAws_json1_1CreateParallelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.translate#ConflictException": @@ -333,10 +332,12 @@ const deserializeAws_json1_1CreateParallelDataCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -368,8 +369,7 @@ const deserializeAws_json1_1DeleteParallelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.translate#ConcurrentModificationException": @@ -385,10 +385,12 @@ const deserializeAws_json1_1DeleteParallelDataCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -417,8 +419,7 @@ const deserializeAws_json1_1DeleteTerminologyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -434,10 +435,12 @@ const deserializeAws_json1_1DeleteTerminologyCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -469,8 +472,7 @@ const deserializeAws_json1_1DescribeTextTranslationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -483,10 +485,12 @@ const deserializeAws_json1_1DescribeTextTranslationJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -518,8 +522,7 @@ const deserializeAws_json1_1GetParallelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -535,10 +538,12 @@ const deserializeAws_json1_1GetParallelDataCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -570,8 +575,7 @@ const deserializeAws_json1_1GetTerminologyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -587,10 +591,12 @@ const deserializeAws_json1_1GetTerminologyCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -622,8 +628,7 @@ const deserializeAws_json1_1ImportTerminologyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -639,10 +644,12 @@ const deserializeAws_json1_1ImportTerminologyCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -674,8 +681,7 @@ const deserializeAws_json1_1ListParallelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -688,10 +694,12 @@ const deserializeAws_json1_1ListParallelDataCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -723,8 +731,7 @@ const deserializeAws_json1_1ListTerminologiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -737,10 +744,12 @@ const deserializeAws_json1_1ListTerminologiesCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -772,8 +781,7 @@ const deserializeAws_json1_1ListTextTranslationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -789,10 +797,12 @@ const deserializeAws_json1_1ListTextTranslationJobsCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -824,8 +834,7 @@ const deserializeAws_json1_1StartTextTranslationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -847,10 +856,12 @@ const deserializeAws_json1_1StartTextTranslationJobCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguagePairExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -882,8 +893,7 @@ const deserializeAws_json1_1StopTextTranslationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.translate#InternalServerException": @@ -896,10 +906,12 @@ const deserializeAws_json1_1StopTextTranslationJobCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -931,8 +943,7 @@ const deserializeAws_json1_1TranslateTextCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DetectedLanguageLowConfidenceException": case "com.amazonaws.translate#DetectedLanguageLowConfidenceException": @@ -960,10 +971,12 @@ const deserializeAws_json1_1TranslateTextCommandError = async ( throw await deserializeAws_json1_1UnsupportedLanguagePairExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -995,8 +1008,7 @@ const deserializeAws_json1_1UpdateParallelDataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.translate#ConcurrentModificationException": @@ -1024,10 +1036,12 @@ const deserializeAws_json1_1UpdateParallelDataCommandError = async ( throw await deserializeAws_json1_1TooManyRequestsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2128,7 +2142,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2154,6 +2168,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-voice-id/src/protocols/Aws_json1_0.ts b/clients/client-voice-id/src/protocols/Aws_json1_0.ts index 431dd36baaab3..ab781a7b43493 100644 --- a/clients/client-voice-id/src/protocols/Aws_json1_0.ts +++ b/clients/client-voice-id/src/protocols/Aws_json1_0.ts @@ -433,8 +433,7 @@ const deserializeAws_json1_0CreateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -459,10 +458,12 @@ const deserializeAws_json1_0CreateDomainCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -491,8 +492,7 @@ const deserializeAws_json1_0DeleteDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -514,10 +514,12 @@ const deserializeAws_json1_0DeleteDomainCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -546,8 +548,7 @@ const deserializeAws_json1_0DeleteFraudsterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -569,10 +570,12 @@ const deserializeAws_json1_0DeleteFraudsterCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -601,8 +604,7 @@ const deserializeAws_json1_0DeleteSpeakerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -624,10 +626,12 @@ const deserializeAws_json1_0DeleteSpeakerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -659,8 +663,7 @@ const deserializeAws_json1_0DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -679,10 +682,12 @@ const deserializeAws_json1_0DescribeDomainCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -714,8 +719,7 @@ const deserializeAws_json1_0DescribeFraudsterCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -734,10 +738,12 @@ const deserializeAws_json1_0DescribeFraudsterCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -769,8 +775,7 @@ const deserializeAws_json1_0DescribeFraudsterRegistrationJobCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -789,10 +794,12 @@ const deserializeAws_json1_0DescribeFraudsterRegistrationJobCommandError = async throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -824,8 +831,7 @@ const deserializeAws_json1_0DescribeSpeakerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -844,10 +850,12 @@ const deserializeAws_json1_0DescribeSpeakerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -879,8 +887,7 @@ const deserializeAws_json1_0DescribeSpeakerEnrollmentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -899,10 +906,12 @@ const deserializeAws_json1_0DescribeSpeakerEnrollmentJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -934,8 +943,7 @@ const deserializeAws_json1_0EvaluateSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -957,10 +965,12 @@ const deserializeAws_json1_0EvaluateSessionCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -992,8 +1002,7 @@ const deserializeAws_json1_0ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1009,10 +1018,12 @@ const deserializeAws_json1_0ListDomainsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1044,8 +1055,7 @@ const deserializeAws_json1_0ListFraudsterRegistrationJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1064,10 +1074,12 @@ const deserializeAws_json1_0ListFraudsterRegistrationJobsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1099,8 +1111,7 @@ const deserializeAws_json1_0ListSpeakerEnrollmentJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1119,10 +1130,12 @@ const deserializeAws_json1_0ListSpeakerEnrollmentJobsCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1154,8 +1167,7 @@ const deserializeAws_json1_0ListSpeakersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1174,10 +1186,12 @@ const deserializeAws_json1_0ListSpeakersCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1209,8 +1223,7 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1229,10 +1242,12 @@ const deserializeAws_json1_0ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1264,8 +1279,7 @@ const deserializeAws_json1_0OptOutSpeakerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1287,10 +1301,12 @@ const deserializeAws_json1_0OptOutSpeakerCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1322,8 +1338,7 @@ const deserializeAws_json1_0StartFraudsterRegistrationJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1348,10 +1363,12 @@ const deserializeAws_json1_0StartFraudsterRegistrationJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1383,8 +1400,7 @@ const deserializeAws_json1_0StartSpeakerEnrollmentJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1409,10 +1425,12 @@ const deserializeAws_json1_0StartSpeakerEnrollmentJobCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1444,8 +1462,7 @@ const deserializeAws_json1_0TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1467,10 +1484,12 @@ const deserializeAws_json1_0TagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1502,8 +1521,7 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1525,10 +1543,12 @@ const deserializeAws_json1_0UntagResourceCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1560,8 +1580,7 @@ const deserializeAws_json1_0UpdateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.voiceid#AccessDeniedException": @@ -1583,10 +1602,12 @@ const deserializeAws_json1_0UpdateDomainCommandError = async ( throw await deserializeAws_json1_0ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2778,7 +2799,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -2804,6 +2825,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-waf-regional/src/protocols/Aws_json1_1.ts b/clients/client-waf-regional/src/protocols/Aws_json1_1.ts index 40f02db364360..4b28df1f654c5 100644 --- a/clients/client-waf-regional/src/protocols/Aws_json1_1.ts +++ b/clients/client-waf-regional/src/protocols/Aws_json1_1.ts @@ -1523,8 +1523,7 @@ const deserializeAws_json1_1AssociateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -1543,10 +1542,12 @@ const deserializeAws_json1_1AssociateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1578,8 +1579,7 @@ const deserializeAws_json1_1CreateByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -1601,10 +1601,12 @@ const deserializeAws_json1_1CreateByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1636,8 +1638,7 @@ const deserializeAws_json1_1CreateGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -1659,10 +1660,12 @@ const deserializeAws_json1_1CreateGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1697,7 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -1717,10 +1719,12 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1752,8 +1756,7 @@ const deserializeAws_json1_1CreateRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -1781,10 +1784,12 @@ const deserializeAws_json1_1CreateRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1816,8 +1821,7 @@ const deserializeAws_json1_1CreateRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -1833,10 +1837,12 @@ const deserializeAws_json1_1CreateRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1868,8 +1874,7 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -1885,10 +1890,12 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1920,8 +1927,7 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -1949,10 +1955,12 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1984,8 +1992,7 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -2010,10 +2017,12 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2045,8 +2054,7 @@ const deserializeAws_json1_1CreateSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -2068,10 +2076,12 @@ const deserializeAws_json1_1CreateSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2103,8 +2113,7 @@ const deserializeAws_json1_1CreateSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -2126,10 +2135,12 @@ const deserializeAws_json1_1CreateSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2161,8 +2172,7 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -2193,10 +2203,12 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2228,8 +2240,7 @@ const deserializeAws_json1_1CreateWebACLMigrationStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFEntityMigrationException": case "com.amazonaws.wafregional#WAFEntityMigrationException": @@ -2248,10 +2259,12 @@ const deserializeAws_json1_1CreateWebACLMigrationStackCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2283,8 +2296,7 @@ const deserializeAws_json1_1CreateXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -2306,10 +2318,12 @@ const deserializeAws_json1_1CreateXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2341,8 +2355,7 @@ const deserializeAws_json1_1DeleteByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2364,10 +2377,12 @@ const deserializeAws_json1_1DeleteByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2399,8 +2414,7 @@ const deserializeAws_json1_1DeleteGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2422,10 +2436,12 @@ const deserializeAws_json1_1DeleteGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2457,8 +2473,7 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2480,10 +2495,12 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2515,8 +2532,7 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2529,10 +2545,12 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2564,8 +2582,7 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2578,10 +2595,12 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2613,8 +2632,7 @@ const deserializeAws_json1_1DeleteRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2642,10 +2660,12 @@ const deserializeAws_json1_1DeleteRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2677,8 +2697,7 @@ const deserializeAws_json1_1DeleteRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2700,10 +2719,12 @@ const deserializeAws_json1_1DeleteRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2735,8 +2756,7 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2758,10 +2778,12 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2793,8 +2815,7 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2822,10 +2843,12 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2857,8 +2880,7 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2886,10 +2908,12 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2921,8 +2945,7 @@ const deserializeAws_json1_1DeleteSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -2944,10 +2967,12 @@ const deserializeAws_json1_1DeleteSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2979,8 +3004,7 @@ const deserializeAws_json1_1DeleteSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3002,10 +3026,12 @@ const deserializeAws_json1_1DeleteSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3037,8 +3063,7 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3066,10 +3091,12 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3101,8 +3128,7 @@ const deserializeAws_json1_1DeleteXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3124,10 +3150,12 @@ const deserializeAws_json1_1DeleteXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3159,8 +3187,7 @@ const deserializeAws_json1_1DisassociateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3176,10 +3203,12 @@ const deserializeAws_json1_1DisassociateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3211,8 +3240,7 @@ const deserializeAws_json1_1GetByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3225,10 +3253,12 @@ const deserializeAws_json1_1GetByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3260,18 +3290,19 @@ const deserializeAws_json1_1GetChangeTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": throw await deserializeAws_json1_1WAFInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3303,8 +3334,7 @@ const deserializeAws_json1_1GetChangeTokenStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3314,10 +3344,12 @@ const deserializeAws_json1_1GetChangeTokenStatusCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3349,8 +3381,7 @@ const deserializeAws_json1_1GetGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3363,10 +3394,12 @@ const deserializeAws_json1_1GetGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3398,8 +3431,7 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3412,10 +3444,12 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3447,8 +3481,7 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3458,10 +3491,12 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3493,8 +3528,7 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3504,10 +3538,12 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3539,8 +3575,7 @@ const deserializeAws_json1_1GetRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3553,10 +3588,12 @@ const deserializeAws_json1_1GetRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3588,8 +3625,7 @@ const deserializeAws_json1_1GetRateBasedRuleManagedKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3605,10 +3641,12 @@ const deserializeAws_json1_1GetRateBasedRuleManagedKeysCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3640,8 +3678,7 @@ const deserializeAws_json1_1GetRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3654,10 +3691,12 @@ const deserializeAws_json1_1GetRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3689,8 +3728,7 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3703,10 +3741,12 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3738,8 +3778,7 @@ const deserializeAws_json1_1GetRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3752,10 +3791,12 @@ const deserializeAws_json1_1GetRuleCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3787,8 +3828,7 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3798,10 +3838,12 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3833,8 +3875,7 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3844,10 +3885,12 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3879,8 +3922,7 @@ const deserializeAws_json1_1GetSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3893,10 +3935,12 @@ const deserializeAws_json1_1GetSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3928,8 +3972,7 @@ const deserializeAws_json1_1GetSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3942,10 +3985,12 @@ const deserializeAws_json1_1GetSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3977,8 +4022,7 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -3991,10 +4035,12 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4026,8 +4072,7 @@ const deserializeAws_json1_1GetWebACLForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4046,10 +4091,12 @@ const deserializeAws_json1_1GetWebACLForResourceCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4081,8 +4128,7 @@ const deserializeAws_json1_1GetXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4095,10 +4141,12 @@ const deserializeAws_json1_1GetXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4130,8 +4178,7 @@ const deserializeAws_json1_1ListActivatedRulesInRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4144,10 +4191,12 @@ const deserializeAws_json1_1ListActivatedRulesInRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4179,8 +4228,7 @@ const deserializeAws_json1_1ListByteMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4190,10 +4238,12 @@ const deserializeAws_json1_1ListByteMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4225,8 +4275,7 @@ const deserializeAws_json1_1ListGeoMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4236,10 +4285,12 @@ const deserializeAws_json1_1ListGeoMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4271,8 +4322,7 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4282,10 +4332,12 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4317,8 +4369,7 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4331,10 +4382,12 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4366,8 +4419,7 @@ const deserializeAws_json1_1ListRateBasedRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4377,10 +4429,12 @@ const deserializeAws_json1_1ListRateBasedRulesCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4412,8 +4466,7 @@ const deserializeAws_json1_1ListRegexMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4423,10 +4476,12 @@ const deserializeAws_json1_1ListRegexMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4458,8 +4513,7 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4469,10 +4523,12 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4504,8 +4560,7 @@ const deserializeAws_json1_1ListResourcesForWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4521,10 +4576,12 @@ const deserializeAws_json1_1ListResourcesForWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4556,18 +4613,19 @@ const deserializeAws_json1_1ListRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": throw await deserializeAws_json1_1WAFInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4599,8 +4657,7 @@ const deserializeAws_json1_1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4610,10 +4667,12 @@ const deserializeAws_json1_1ListRulesCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4645,8 +4704,7 @@ const deserializeAws_json1_1ListSizeConstraintSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4656,10 +4714,12 @@ const deserializeAws_json1_1ListSizeConstraintSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4691,8 +4751,7 @@ const deserializeAws_json1_1ListSqlInjectionMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4702,10 +4761,12 @@ const deserializeAws_json1_1ListSqlInjectionMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4737,8 +4798,7 @@ const deserializeAws_json1_1ListSubscribedRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4748,10 +4808,12 @@ const deserializeAws_json1_1ListSubscribedRuleGroupsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4783,8 +4845,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -4806,10 +4867,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4841,8 +4904,7 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4852,10 +4914,12 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4887,8 +4951,7 @@ const deserializeAws_json1_1ListXssMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4898,10 +4961,12 @@ const deserializeAws_json1_1ListXssMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4933,8 +4998,7 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -4950,10 +5014,12 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4985,8 +5051,7 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5002,10 +5067,12 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5037,8 +5104,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -5063,10 +5129,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5098,8 +5166,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.wafregional#WAFBadRequestException": @@ -5121,10 +5188,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5156,8 +5225,7 @@ const deserializeAws_json1_1UpdateByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5185,10 +5253,12 @@ const deserializeAws_json1_1UpdateByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5220,8 +5290,7 @@ const deserializeAws_json1_1UpdateGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5252,10 +5321,12 @@ const deserializeAws_json1_1UpdateGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5287,8 +5358,7 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5319,10 +5389,12 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5354,8 +5426,7 @@ const deserializeAws_json1_1UpdateRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5386,10 +5457,12 @@ const deserializeAws_json1_1UpdateRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5421,8 +5494,7 @@ const deserializeAws_json1_1UpdateRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.wafregional#WAFDisallowedNameException": @@ -5450,10 +5522,12 @@ const deserializeAws_json1_1UpdateRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5485,8 +5559,7 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5514,10 +5587,12 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5549,8 +5624,7 @@ const deserializeAws_json1_1UpdateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5581,10 +5655,12 @@ const deserializeAws_json1_1UpdateRuleCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5616,8 +5692,7 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5642,10 +5717,12 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5677,8 +5754,7 @@ const deserializeAws_json1_1UpdateSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5709,10 +5785,12 @@ const deserializeAws_json1_1UpdateSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5744,8 +5822,7 @@ const deserializeAws_json1_1UpdateSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5773,10 +5850,12 @@ const deserializeAws_json1_1UpdateSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5808,8 +5887,7 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5843,10 +5921,12 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFSubscriptionNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5878,8 +5958,7 @@ const deserializeAws_json1_1UpdateXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafregional#WAFInternalErrorException": @@ -5907,10 +5986,12 @@ const deserializeAws_json1_1UpdateXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -9249,7 +9330,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -9275,6 +9356,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-waf/src/protocols/Aws_json1_1.ts b/clients/client-waf/src/protocols/Aws_json1_1.ts index ddf816722c203..c30a14e04204f 100644 --- a/clients/client-waf/src/protocols/Aws_json1_1.ts +++ b/clients/client-waf/src/protocols/Aws_json1_1.ts @@ -1452,8 +1452,7 @@ const deserializeAws_json1_1CreateByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1475,10 +1474,12 @@ const deserializeAws_json1_1CreateByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1510,8 +1511,7 @@ const deserializeAws_json1_1CreateGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1533,10 +1533,12 @@ const deserializeAws_json1_1CreateGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1568,8 +1570,7 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1591,10 +1592,12 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1626,8 +1629,7 @@ const deserializeAws_json1_1CreateRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -1655,10 +1657,12 @@ const deserializeAws_json1_1CreateRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1690,8 +1694,7 @@ const deserializeAws_json1_1CreateRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1707,10 +1710,12 @@ const deserializeAws_json1_1CreateRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1742,8 +1747,7 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1759,10 +1763,12 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1794,8 +1800,7 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -1823,10 +1828,12 @@ const deserializeAws_json1_1CreateRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1858,8 +1865,7 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -1884,10 +1890,12 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1919,8 +1927,7 @@ const deserializeAws_json1_1CreateSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -1942,10 +1949,12 @@ const deserializeAws_json1_1CreateSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1977,8 +1986,7 @@ const deserializeAws_json1_1CreateSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -2000,10 +2008,12 @@ const deserializeAws_json1_1CreateSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2035,8 +2045,7 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -2067,10 +2076,12 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2102,8 +2113,7 @@ const deserializeAws_json1_1CreateWebACLMigrationStackCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFEntityMigrationException": case "com.amazonaws.waf#WAFEntityMigrationException": @@ -2122,10 +2132,12 @@ const deserializeAws_json1_1CreateWebACLMigrationStackCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2157,8 +2169,7 @@ const deserializeAws_json1_1CreateXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -2180,10 +2191,12 @@ const deserializeAws_json1_1CreateXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2215,8 +2228,7 @@ const deserializeAws_json1_1DeleteByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2238,10 +2250,12 @@ const deserializeAws_json1_1DeleteByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2273,8 +2287,7 @@ const deserializeAws_json1_1DeleteGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2296,10 +2309,12 @@ const deserializeAws_json1_1DeleteGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2331,8 +2346,7 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2354,10 +2368,12 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2389,8 +2405,7 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2403,10 +2418,12 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2438,8 +2455,7 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2452,10 +2468,12 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2487,8 +2505,7 @@ const deserializeAws_json1_1DeleteRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2516,10 +2533,12 @@ const deserializeAws_json1_1DeleteRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2551,8 +2570,7 @@ const deserializeAws_json1_1DeleteRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2574,10 +2592,12 @@ const deserializeAws_json1_1DeleteRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2609,8 +2629,7 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2632,10 +2651,12 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2667,8 +2688,7 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2696,10 +2716,12 @@ const deserializeAws_json1_1DeleteRuleCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2731,8 +2753,7 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2760,10 +2781,12 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2795,8 +2818,7 @@ const deserializeAws_json1_1DeleteSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2818,10 +2840,12 @@ const deserializeAws_json1_1DeleteSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2853,8 +2877,7 @@ const deserializeAws_json1_1DeleteSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2876,10 +2899,12 @@ const deserializeAws_json1_1DeleteSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2911,8 +2936,7 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2940,10 +2964,12 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2975,8 +3001,7 @@ const deserializeAws_json1_1DeleteXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -2998,10 +3023,12 @@ const deserializeAws_json1_1DeleteXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3033,8 +3060,7 @@ const deserializeAws_json1_1GetByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3047,10 +3073,12 @@ const deserializeAws_json1_1GetByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3082,18 +3110,19 @@ const deserializeAws_json1_1GetChangeTokenCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": throw await deserializeAws_json1_1WAFInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3125,8 +3154,7 @@ const deserializeAws_json1_1GetChangeTokenStatusCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3136,10 +3164,12 @@ const deserializeAws_json1_1GetChangeTokenStatusCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3171,8 +3201,7 @@ const deserializeAws_json1_1GetGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3185,10 +3214,12 @@ const deserializeAws_json1_1GetGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3220,8 +3251,7 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3234,10 +3264,12 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3269,8 +3301,7 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3280,10 +3311,12 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3315,8 +3348,7 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3326,10 +3358,12 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3361,8 +3395,7 @@ const deserializeAws_json1_1GetRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3375,10 +3408,12 @@ const deserializeAws_json1_1GetRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3410,8 +3445,7 @@ const deserializeAws_json1_1GetRateBasedRuleManagedKeysCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3427,10 +3461,12 @@ const deserializeAws_json1_1GetRateBasedRuleManagedKeysCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3462,8 +3498,7 @@ const deserializeAws_json1_1GetRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3476,10 +3511,12 @@ const deserializeAws_json1_1GetRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3511,8 +3548,7 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3525,10 +3561,12 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3560,8 +3598,7 @@ const deserializeAws_json1_1GetRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3574,10 +3611,12 @@ const deserializeAws_json1_1GetRuleCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3609,8 +3648,7 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3620,10 +3658,12 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3655,8 +3695,7 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3666,10 +3705,12 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3701,8 +3742,7 @@ const deserializeAws_json1_1GetSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3715,10 +3755,12 @@ const deserializeAws_json1_1GetSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3750,8 +3792,7 @@ const deserializeAws_json1_1GetSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3764,10 +3805,12 @@ const deserializeAws_json1_1GetSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3799,8 +3842,7 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3813,10 +3855,12 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3848,8 +3892,7 @@ const deserializeAws_json1_1GetXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3862,10 +3905,12 @@ const deserializeAws_json1_1GetXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3897,8 +3942,7 @@ const deserializeAws_json1_1ListActivatedRulesInRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3911,10 +3955,12 @@ const deserializeAws_json1_1ListActivatedRulesInRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3946,8 +3992,7 @@ const deserializeAws_json1_1ListByteMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -3957,10 +4002,12 @@ const deserializeAws_json1_1ListByteMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3992,8 +4039,7 @@ const deserializeAws_json1_1ListGeoMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4003,10 +4049,12 @@ const deserializeAws_json1_1ListGeoMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4038,8 +4086,7 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4049,10 +4096,12 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4084,8 +4133,7 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4098,10 +4146,12 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4133,8 +4183,7 @@ const deserializeAws_json1_1ListRateBasedRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4144,10 +4193,12 @@ const deserializeAws_json1_1ListRateBasedRulesCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4179,8 +4230,7 @@ const deserializeAws_json1_1ListRegexMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4190,10 +4240,12 @@ const deserializeAws_json1_1ListRegexMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4225,8 +4277,7 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4236,10 +4287,12 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4271,18 +4324,19 @@ const deserializeAws_json1_1ListRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": throw await deserializeAws_json1_1WAFInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4314,8 +4368,7 @@ const deserializeAws_json1_1ListRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4325,10 +4378,12 @@ const deserializeAws_json1_1ListRulesCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4360,8 +4415,7 @@ const deserializeAws_json1_1ListSizeConstraintSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4371,10 +4425,12 @@ const deserializeAws_json1_1ListSizeConstraintSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4406,8 +4462,7 @@ const deserializeAws_json1_1ListSqlInjectionMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4417,10 +4472,12 @@ const deserializeAws_json1_1ListSqlInjectionMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4452,8 +4509,7 @@ const deserializeAws_json1_1ListSubscribedRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4463,10 +4519,12 @@ const deserializeAws_json1_1ListSubscribedRuleGroupsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4498,8 +4556,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -4521,10 +4578,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4556,8 +4615,7 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4567,10 +4625,12 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4602,8 +4662,7 @@ const deserializeAws_json1_1ListXssMatchSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4613,10 +4672,12 @@ const deserializeAws_json1_1ListXssMatchSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidAccountExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4648,8 +4709,7 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4665,10 +4725,12 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4700,8 +4762,7 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4717,10 +4778,12 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4752,8 +4815,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -4778,10 +4840,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4813,8 +4877,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFBadRequestException": case "com.amazonaws.waf#WAFBadRequestException": @@ -4836,10 +4899,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4871,8 +4936,7 @@ const deserializeAws_json1_1UpdateByteMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4900,10 +4964,12 @@ const deserializeAws_json1_1UpdateByteMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4935,8 +5001,7 @@ const deserializeAws_json1_1UpdateGeoMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -4967,10 +5032,12 @@ const deserializeAws_json1_1UpdateGeoMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5002,8 +5069,7 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5034,10 +5100,12 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5069,8 +5137,7 @@ const deserializeAws_json1_1UpdateRateBasedRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5101,10 +5168,12 @@ const deserializeAws_json1_1UpdateRateBasedRuleCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5136,8 +5205,7 @@ const deserializeAws_json1_1UpdateRegexMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDisallowedNameException": case "com.amazonaws.waf#WAFDisallowedNameException": @@ -5165,10 +5233,12 @@ const deserializeAws_json1_1UpdateRegexMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5200,8 +5270,7 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5229,10 +5298,12 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5264,8 +5335,7 @@ const deserializeAws_json1_1UpdateRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5296,10 +5366,12 @@ const deserializeAws_json1_1UpdateRuleCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5331,8 +5403,7 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5357,10 +5428,12 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5392,8 +5465,7 @@ const deserializeAws_json1_1UpdateSizeConstraintSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5424,10 +5496,12 @@ const deserializeAws_json1_1UpdateSizeConstraintSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5459,8 +5533,7 @@ const deserializeAws_json1_1UpdateSqlInjectionMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5488,10 +5561,12 @@ const deserializeAws_json1_1UpdateSqlInjectionMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5523,8 +5598,7 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5558,10 +5632,12 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFSubscriptionNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5593,8 +5669,7 @@ const deserializeAws_json1_1UpdateXssMatchSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.waf#WAFInternalErrorException": @@ -5622,10 +5697,12 @@ const deserializeAws_json1_1UpdateXssMatchSetCommandError = async ( throw await deserializeAws_json1_1WAFStaleDataExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -8857,7 +8934,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -8883,6 +8960,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-wafv2/src/protocols/Aws_json1_1.ts b/clients/client-wafv2/src/protocols/Aws_json1_1.ts index 3b624b9a23878..e96c5c89511d8 100644 --- a/clients/client-wafv2/src/protocols/Aws_json1_1.ts +++ b/clients/client-wafv2/src/protocols/Aws_json1_1.ts @@ -999,8 +999,7 @@ const deserializeAws_json1_1AssociateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1019,10 +1018,12 @@ const deserializeAws_json1_1AssociateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1054,8 +1055,7 @@ const deserializeAws_json1_1CheckCapacityCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFExpiredManagedRuleGroupVersionException": case "com.amazonaws.wafv2#WAFExpiredManagedRuleGroupVersionException": @@ -1083,10 +1083,12 @@ const deserializeAws_json1_1CheckCapacityCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1118,8 +1120,7 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDuplicateItemException": case "com.amazonaws.wafv2#WAFDuplicateItemException": @@ -1147,10 +1148,12 @@ const deserializeAws_json1_1CreateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1182,8 +1185,7 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDuplicateItemException": case "com.amazonaws.wafv2#WAFDuplicateItemException": @@ -1211,10 +1213,12 @@ const deserializeAws_json1_1CreateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1246,8 +1250,7 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDuplicateItemException": case "com.amazonaws.wafv2#WAFDuplicateItemException": @@ -1284,10 +1287,12 @@ const deserializeAws_json1_1CreateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1319,8 +1324,7 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFConfigurationWarningException": case "com.amazonaws.wafv2#WAFConfigurationWarningException": @@ -1363,10 +1367,12 @@ const deserializeAws_json1_1CreateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1398,8 +1404,7 @@ const deserializeAws_json1_1DeleteFirewallManagerRuleGroupsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1418,10 +1423,12 @@ const deserializeAws_json1_1DeleteFirewallManagerRuleGroupsCommandError = async throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1453,8 +1460,7 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFAssociatedItemException": case "com.amazonaws.wafv2#WAFAssociatedItemException": @@ -1482,10 +1488,12 @@ const deserializeAws_json1_1DeleteIPSetCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1517,8 +1525,7 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1537,10 +1544,12 @@ const deserializeAws_json1_1DeleteLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1572,8 +1581,7 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1586,10 +1594,12 @@ const deserializeAws_json1_1DeletePermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1621,8 +1631,7 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFAssociatedItemException": case "com.amazonaws.wafv2#WAFAssociatedItemException": @@ -1650,10 +1659,12 @@ const deserializeAws_json1_1DeleteRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1685,8 +1696,7 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFAssociatedItemException": case "com.amazonaws.wafv2#WAFAssociatedItemException": @@ -1714,10 +1724,12 @@ const deserializeAws_json1_1DeleteRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1749,8 +1761,7 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFAssociatedItemException": case "com.amazonaws.wafv2#WAFAssociatedItemException": @@ -1778,10 +1789,12 @@ const deserializeAws_json1_1DeleteWebACLCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1813,8 +1826,7 @@ const deserializeAws_json1_1DescribeManagedRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFExpiredManagedRuleGroupVersionException": case "com.amazonaws.wafv2#WAFExpiredManagedRuleGroupVersionException": @@ -1836,10 +1848,12 @@ const deserializeAws_json1_1DescribeManagedRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1871,8 +1885,7 @@ const deserializeAws_json1_1DisassociateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1888,10 +1901,12 @@ const deserializeAws_json1_1DisassociateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1923,8 +1938,7 @@ const deserializeAws_json1_1GenerateMobileSdkReleaseUrlCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1940,10 +1954,12 @@ const deserializeAws_json1_1GenerateMobileSdkReleaseUrlCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1975,8 +1991,7 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -1992,10 +2007,12 @@ const deserializeAws_json1_1GetIPSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2027,8 +2044,7 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2044,10 +2060,12 @@ const deserializeAws_json1_1GetLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2079,8 +2097,7 @@ const deserializeAws_json1_1GetManagedRuleSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2096,10 +2113,12 @@ const deserializeAws_json1_1GetManagedRuleSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2131,8 +2150,7 @@ const deserializeAws_json1_1GetMobileSdkReleaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2148,10 +2166,12 @@ const deserializeAws_json1_1GetMobileSdkReleaseCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2183,8 +2203,7 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2197,10 +2216,12 @@ const deserializeAws_json1_1GetPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2232,8 +2253,7 @@ const deserializeAws_json1_1GetRateBasedStatementManagedKeysCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2249,10 +2269,12 @@ const deserializeAws_json1_1GetRateBasedStatementManagedKeysCommandError = async throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2284,8 +2306,7 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2301,10 +2322,12 @@ const deserializeAws_json1_1GetRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2336,8 +2359,7 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2353,10 +2375,12 @@ const deserializeAws_json1_1GetRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2388,8 +2412,7 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2402,10 +2425,12 @@ const deserializeAws_json1_1GetSampledRequestsCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2437,8 +2462,7 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2454,10 +2478,12 @@ const deserializeAws_json1_1GetWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2489,8 +2515,7 @@ const deserializeAws_json1_1GetWebACLForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2509,10 +2534,12 @@ const deserializeAws_json1_1GetWebACLForResourceCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2544,8 +2571,7 @@ const deserializeAws_json1_1ListAvailableManagedRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2558,10 +2584,12 @@ const deserializeAws_json1_1ListAvailableManagedRuleGroupsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2593,8 +2621,7 @@ const deserializeAws_json1_1ListAvailableManagedRuleGroupVersionsCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2610,10 +2637,12 @@ const deserializeAws_json1_1ListAvailableManagedRuleGroupVersionsCommandError = throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2645,8 +2674,7 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2659,10 +2687,12 @@ const deserializeAws_json1_1ListIPSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2694,8 +2724,7 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2708,10 +2737,12 @@ const deserializeAws_json1_1ListLoggingConfigurationsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2743,8 +2774,7 @@ const deserializeAws_json1_1ListManagedRuleSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2757,10 +2787,12 @@ const deserializeAws_json1_1ListManagedRuleSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2792,8 +2824,7 @@ const deserializeAws_json1_1ListMobileSdkReleasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2806,10 +2837,12 @@ const deserializeAws_json1_1ListMobileSdkReleasesCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2841,8 +2874,7 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2855,10 +2887,12 @@ const deserializeAws_json1_1ListRegexPatternSetsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2890,8 +2924,7 @@ const deserializeAws_json1_1ListResourcesForWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2907,10 +2940,12 @@ const deserializeAws_json1_1ListResourcesForWebACLCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2942,8 +2977,7 @@ const deserializeAws_json1_1ListRuleGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -2956,10 +2990,12 @@ const deserializeAws_json1_1ListRuleGroupsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2991,8 +3027,7 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3014,10 +3049,12 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3049,8 +3086,7 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3063,10 +3099,12 @@ const deserializeAws_json1_1ListWebACLsCommandError = async ( throw await deserializeAws_json1_1WAFInvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3098,8 +3136,7 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3127,10 +3164,12 @@ const deserializeAws_json1_1PutLoggingConfigurationCommandError = async ( throw await deserializeAws_json1_1WAFServiceLinkedRoleErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3162,8 +3201,7 @@ const deserializeAws_json1_1PutManagedRuleSetVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3182,10 +3220,12 @@ const deserializeAws_json1_1PutManagedRuleSetVersionsCommandError = async ( throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3217,8 +3257,7 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3234,10 +3273,12 @@ const deserializeAws_json1_1PutPermissionPolicyCommandError = async ( throw await deserializeAws_json1_1WAFNonexistentItemExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3269,8 +3310,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3295,10 +3335,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3330,8 +3372,7 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3353,10 +3394,12 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( throw await deserializeAws_json1_1WAFTagOperationInternalErrorExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3388,8 +3431,7 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDuplicateItemException": case "com.amazonaws.wafv2#WAFDuplicateItemException": @@ -3414,10 +3456,12 @@ const deserializeAws_json1_1UpdateIPSetCommandError = async ( throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3449,8 +3493,7 @@ const deserializeAws_json1_1UpdateManagedRuleSetVersionExpiryDateCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFInternalErrorException": case "com.amazonaws.wafv2#WAFInternalErrorException": @@ -3469,10 +3512,12 @@ const deserializeAws_json1_1UpdateManagedRuleSetVersionExpiryDateCommandError = throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3504,8 +3549,7 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFDuplicateItemException": case "com.amazonaws.wafv2#WAFDuplicateItemException": @@ -3530,10 +3574,12 @@ const deserializeAws_json1_1UpdateRegexPatternSetCommandError = async ( throw await deserializeAws_json1_1WAFOptimisticLockExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3565,8 +3611,7 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFConfigurationWarningException": case "com.amazonaws.wafv2#WAFConfigurationWarningException": @@ -3600,10 +3645,12 @@ const deserializeAws_json1_1UpdateRuleGroupCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3635,8 +3682,7 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "WAFConfigurationWarningException": case "com.amazonaws.wafv2#WAFConfigurationWarningException": @@ -3676,10 +3722,12 @@ const deserializeAws_json1_1UpdateWebACLCommandError = async ( throw await deserializeAws_json1_1WAFUnavailableEntityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7698,7 +7746,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7724,6 +7772,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-wellarchitected/src/protocols/Aws_restJson1.ts b/clients/client-wellarchitected/src/protocols/Aws_restJson1.ts index 6030406af29d2..8be42c29c237d 100644 --- a/clients/client-wellarchitected/src/protocols/Aws_restJson1.ts +++ b/clients/client-wellarchitected/src/protocols/Aws_restJson1.ts @@ -1619,8 +1619,7 @@ const deserializeAws_restJson1AssociateLensesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1642,10 +1641,12 @@ const deserializeAws_restJson1AssociateLensesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1678,8 +1679,7 @@ const deserializeAws_restJson1CreateLensShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1704,10 +1704,12 @@ const deserializeAws_restJson1CreateLensShareCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1744,8 +1746,7 @@ const deserializeAws_restJson1CreateLensVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1770,10 +1771,12 @@ const deserializeAws_restJson1CreateLensVersionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1810,8 +1813,7 @@ const deserializeAws_restJson1CreateMilestoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1836,10 +1838,12 @@ const deserializeAws_restJson1CreateMilestoneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1876,8 +1880,7 @@ const deserializeAws_restJson1CreateWorkloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1899,10 +1902,12 @@ const deserializeAws_restJson1CreateWorkloadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1939,8 +1944,7 @@ const deserializeAws_restJson1CreateWorkloadShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -1965,10 +1969,12 @@ const deserializeAws_restJson1CreateWorkloadShareCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1997,8 +2003,7 @@ const deserializeAws_restJson1DeleteLensCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2020,10 +2025,12 @@ const deserializeAws_restJson1DeleteLensCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2052,8 +2059,7 @@ const deserializeAws_restJson1DeleteLensShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2075,10 +2081,12 @@ const deserializeAws_restJson1DeleteLensShareCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2107,8 +2115,7 @@ const deserializeAws_restJson1DeleteWorkloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2130,10 +2137,12 @@ const deserializeAws_restJson1DeleteWorkloadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2162,8 +2171,7 @@ const deserializeAws_restJson1DeleteWorkloadShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2185,10 +2193,12 @@ const deserializeAws_restJson1DeleteWorkloadShareCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2217,8 +2227,7 @@ const deserializeAws_restJson1DisassociateLensesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2240,10 +2249,12 @@ const deserializeAws_restJson1DisassociateLensesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2276,8 +2287,7 @@ const deserializeAws_restJson1ExportLensCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2296,10 +2306,12 @@ const deserializeAws_restJson1ExportLensCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2348,8 +2360,7 @@ const deserializeAws_restJson1GetAnswerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2368,10 +2379,12 @@ const deserializeAws_restJson1GetAnswerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2404,8 +2417,7 @@ const deserializeAws_restJson1GetLensCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2424,10 +2436,12 @@ const deserializeAws_restJson1GetLensCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2468,8 +2482,7 @@ const deserializeAws_restJson1GetLensReviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2488,10 +2501,12 @@ const deserializeAws_restJson1GetLensReviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2532,8 +2547,7 @@ const deserializeAws_restJson1GetLensReviewReportCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2552,10 +2566,12 @@ const deserializeAws_restJson1GetLensReviewReportCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2608,8 +2624,7 @@ const deserializeAws_restJson1GetLensVersionDifferenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2628,10 +2643,12 @@ const deserializeAws_restJson1GetLensVersionDifferenceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2668,8 +2685,7 @@ const deserializeAws_restJson1GetMilestoneCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2688,10 +2704,12 @@ const deserializeAws_restJson1GetMilestoneCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2724,8 +2742,7 @@ const deserializeAws_restJson1GetWorkloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2744,10 +2761,12 @@ const deserializeAws_restJson1GetWorkloadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2784,8 +2803,7 @@ const deserializeAws_restJson1ImportLensCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2810,10 +2828,12 @@ const deserializeAws_restJson1ImportLensCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2866,8 +2886,7 @@ const deserializeAws_restJson1ListAnswersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2886,10 +2905,12 @@ const deserializeAws_restJson1ListAnswersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2926,8 +2947,7 @@ const deserializeAws_restJson1ListLensesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -2943,10 +2963,12 @@ const deserializeAws_restJson1ListLensesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2999,8 +3021,7 @@ const deserializeAws_restJson1ListLensReviewImprovementsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3019,10 +3040,12 @@ const deserializeAws_restJson1ListLensReviewImprovementsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3067,8 +3090,7 @@ const deserializeAws_restJson1ListLensReviewsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3087,10 +3109,12 @@ const deserializeAws_restJson1ListLensReviewsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3127,8 +3151,7 @@ const deserializeAws_restJson1ListLensSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3147,10 +3170,12 @@ const deserializeAws_restJson1ListLensSharesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3191,8 +3216,7 @@ const deserializeAws_restJson1ListMilestonesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3211,10 +3235,12 @@ const deserializeAws_restJson1ListMilestonesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3251,8 +3277,7 @@ const deserializeAws_restJson1ListNotificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3268,10 +3293,12 @@ const deserializeAws_restJson1ListNotificationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3311,8 +3338,7 @@ const deserializeAws_restJson1ListShareInvitationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3328,10 +3354,12 @@ const deserializeAws_restJson1ListShareInvitationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3364,8 +3392,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.wellarchitected#InternalServerException": @@ -3375,10 +3402,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3415,8 +3444,7 @@ const deserializeAws_restJson1ListWorkloadsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3432,10 +3460,12 @@ const deserializeAws_restJson1ListWorkloadsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3479,8 +3509,7 @@ const deserializeAws_restJson1ListWorkloadSharesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3499,10 +3528,12 @@ const deserializeAws_restJson1ListWorkloadSharesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3531,8 +3562,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.wellarchitected#InternalServerException": @@ -3542,10 +3572,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3574,8 +3606,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerException": case "com.amazonaws.wellarchitected#InternalServerException": @@ -3585,10 +3616,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3633,8 +3666,7 @@ const deserializeAws_restJson1UpdateAnswerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3656,10 +3688,12 @@ const deserializeAws_restJson1UpdateAnswerCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3696,8 +3730,7 @@ const deserializeAws_restJson1UpdateLensReviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3719,10 +3752,12 @@ const deserializeAws_restJson1UpdateLensReviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3755,8 +3790,7 @@ const deserializeAws_restJson1UpdateShareInvitationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3778,10 +3812,12 @@ const deserializeAws_restJson1UpdateShareInvitationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3814,8 +3850,7 @@ const deserializeAws_restJson1UpdateWorkloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3837,10 +3872,12 @@ const deserializeAws_restJson1UpdateWorkloadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3877,8 +3914,7 @@ const deserializeAws_restJson1UpdateWorkloadShareCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3900,10 +3936,12 @@ const deserializeAws_restJson1UpdateWorkloadShareCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3932,8 +3970,7 @@ const deserializeAws_restJson1UpgradeLensReviewCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wellarchitected#AccessDeniedException": @@ -3955,10 +3992,12 @@ const deserializeAws_restJson1UpgradeLensReviewCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5069,7 +5108,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5095,6 +5134,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-wisdom/src/protocols/Aws_restJson1.ts b/clients/client-wisdom/src/protocols/Aws_restJson1.ts index e43028bc62926..68851851b03fb 100644 --- a/clients/client-wisdom/src/protocols/Aws_restJson1.ts +++ b/clients/client-wisdom/src/protocols/Aws_restJson1.ts @@ -1269,8 +1269,7 @@ const deserializeAws_restJson1CreateAssistantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1286,10 +1285,12 @@ const deserializeAws_restJson1CreateAssistantCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1325,8 +1326,7 @@ const deserializeAws_restJson1CreateAssistantAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1345,10 +1345,12 @@ const deserializeAws_restJson1CreateAssistantAssociationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1381,8 +1383,7 @@ const deserializeAws_restJson1CreateContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1401,10 +1402,12 @@ const deserializeAws_restJson1CreateContentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1437,8 +1440,7 @@ const deserializeAws_restJson1CreateKnowledgeBaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1454,10 +1456,12 @@ const deserializeAws_restJson1CreateKnowledgeBaseCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1490,8 +1494,7 @@ const deserializeAws_restJson1CreateSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictException": case "com.amazonaws.wisdom#ConflictException": @@ -1504,10 +1507,12 @@ const deserializeAws_restJson1CreateSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1536,8 +1541,7 @@ const deserializeAws_restJson1DeleteAssistantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1550,10 +1554,12 @@ const deserializeAws_restJson1DeleteAssistantCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1582,8 +1588,7 @@ const deserializeAws_restJson1DeleteAssistantAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1596,10 +1601,12 @@ const deserializeAws_restJson1DeleteAssistantAssociationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1628,8 +1635,7 @@ const deserializeAws_restJson1DeleteContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1642,10 +1648,12 @@ const deserializeAws_restJson1DeleteContentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1674,8 +1682,7 @@ const deserializeAws_restJson1DeleteKnowledgeBaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1691,10 +1698,12 @@ const deserializeAws_restJson1DeleteKnowledgeBaseCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1727,8 +1736,7 @@ const deserializeAws_restJson1GetAssistantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1741,10 +1749,12 @@ const deserializeAws_restJson1GetAssistantCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1780,8 +1790,7 @@ const deserializeAws_restJson1GetAssistantAssociationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1794,10 +1803,12 @@ const deserializeAws_restJson1GetAssistantAssociationCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1830,8 +1841,7 @@ const deserializeAws_restJson1GetContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1844,10 +1854,12 @@ const deserializeAws_restJson1GetContentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1880,8 +1892,7 @@ const deserializeAws_restJson1GetContentSummaryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1894,10 +1905,12 @@ const deserializeAws_restJson1GetContentSummaryCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1930,8 +1943,7 @@ const deserializeAws_restJson1GetKnowledgeBaseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1944,10 +1956,12 @@ const deserializeAws_restJson1GetKnowledgeBaseCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1984,8 +1998,7 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -1998,10 +2011,12 @@ const deserializeAws_restJson1GetRecommendationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2034,8 +2049,7 @@ const deserializeAws_restJson1GetSessionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2048,10 +2062,12 @@ const deserializeAws_restJson1GetSessionCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2091,8 +2107,7 @@ const deserializeAws_restJson1ListAssistantAssociationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2105,10 +2120,12 @@ const deserializeAws_restJson1ListAssistantAssociationsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2145,8 +2162,7 @@ const deserializeAws_restJson1ListAssistantsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2156,10 +2172,12 @@ const deserializeAws_restJson1ListAssistantsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2196,8 +2214,7 @@ const deserializeAws_restJson1ListContentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2210,10 +2227,12 @@ const deserializeAws_restJson1ListContentsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2250,8 +2269,7 @@ const deserializeAws_restJson1ListKnowledgeBasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2261,10 +2279,12 @@ const deserializeAws_restJson1ListKnowledgeBasesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2297,18 +2317,19 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.wisdom#ResourceNotFoundException": throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2345,8 +2366,7 @@ const deserializeAws_restJson1NotifyRecommendationsReceivedCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2359,10 +2379,12 @@ const deserializeAws_restJson1NotifyRecommendationsReceivedCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2399,8 +2421,7 @@ const deserializeAws_restJson1QueryAssistantCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2413,10 +2434,12 @@ const deserializeAws_restJson1QueryAssistantCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2445,8 +2468,7 @@ const deserializeAws_restJson1RemoveKnowledgeBaseTemplateUriCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2459,10 +2481,12 @@ const deserializeAws_restJson1RemoveKnowledgeBaseTemplateUriCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2499,8 +2523,7 @@ const deserializeAws_restJson1SearchContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2513,10 +2536,12 @@ const deserializeAws_restJson1SearchContentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2553,8 +2578,7 @@ const deserializeAws_restJson1SearchSessionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2567,10 +2591,12 @@ const deserializeAws_restJson1SearchSessionsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2615,8 +2641,7 @@ const deserializeAws_restJson1StartContentUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2629,10 +2654,12 @@ const deserializeAws_restJson1StartContentUploadCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2661,8 +2688,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.wisdom#ResourceNotFoundException": @@ -2672,10 +2698,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2704,18 +2732,19 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.wisdom#ResourceNotFoundException": throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2748,8 +2777,7 @@ const deserializeAws_restJson1UpdateContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2765,10 +2793,12 @@ const deserializeAws_restJson1UpdateContentCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2801,8 +2831,7 @@ const deserializeAws_restJson1UpdateKnowledgeBaseTemplateUriCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.wisdom#AccessDeniedException": @@ -2815,10 +2844,12 @@ const deserializeAws_restJson1UpdateKnowledgeBaseTemplateUriCommandError = async throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3677,7 +3708,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3703,6 +3734,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-workdocs/src/protocols/Aws_restJson1.ts b/clients/client-workdocs/src/protocols/Aws_restJson1.ts index e11786c1c618e..4f42b269db264 100644 --- a/clients/client-workdocs/src/protocols/Aws_restJson1.ts +++ b/clients/client-workdocs/src/protocols/Aws_restJson1.ts @@ -1677,8 +1677,7 @@ const deserializeAws_restJson1AbortDocumentVersionUploadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -1700,10 +1699,12 @@ const deserializeAws_restJson1AbortDocumentVersionUploadCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1736,8 +1737,7 @@ const deserializeAws_restJson1ActivateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -1756,10 +1756,12 @@ const deserializeAws_restJson1ActivateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1792,8 +1794,7 @@ const deserializeAws_restJson1AddResourcePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -1809,10 +1810,12 @@ const deserializeAws_restJson1AddResourcePermissionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1845,8 +1848,7 @@ const deserializeAws_restJson1CreateCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentLockedForCommentsException": case "com.amazonaws.workdocs#DocumentLockedForCommentsException": @@ -1874,10 +1876,12 @@ const deserializeAws_restJson1CreateCommentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1906,8 +1910,7 @@ const deserializeAws_restJson1CreateCustomMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "CustomMetadataLimitExceededException": case "com.amazonaws.workdocs#CustomMetadataLimitExceededException": @@ -1932,10 +1935,12 @@ const deserializeAws_restJson1CreateCustomMetadataCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1968,8 +1973,7 @@ const deserializeAws_restJson1CreateFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.workdocs#ConflictingOperationException": @@ -2000,10 +2004,12 @@ const deserializeAws_restJson1CreateFolderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2032,8 +2038,7 @@ const deserializeAws_restJson1CreateLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2055,10 +2060,12 @@ const deserializeAws_restJson1CreateLabelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2091,8 +2098,7 @@ const deserializeAws_restJson1CreateNotificationSubscriptionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ServiceUnavailableException": case "com.amazonaws.workdocs#ServiceUnavailableException": @@ -2105,10 +2111,12 @@ const deserializeAws_restJson1CreateNotificationSubscriptionCommandError = async throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2141,8 +2149,7 @@ const deserializeAws_restJson1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityAlreadyExistsException": case "com.amazonaws.workdocs#EntityAlreadyExistsException": @@ -2161,10 +2168,12 @@ const deserializeAws_restJson1CreateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2193,8 +2202,7 @@ const deserializeAws_restJson1DeactivateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2213,10 +2221,12 @@ const deserializeAws_restJson1DeactivateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2245,8 +2255,7 @@ const deserializeAws_restJson1DeleteCommentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DocumentLockedForCommentsException": case "com.amazonaws.workdocs#DocumentLockedForCommentsException": @@ -2271,10 +2280,12 @@ const deserializeAws_restJson1DeleteCommentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2303,8 +2314,7 @@ const deserializeAws_restJson1DeleteCustomMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2326,10 +2336,12 @@ const deserializeAws_restJson1DeleteCustomMetadataCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2358,8 +2370,7 @@ const deserializeAws_restJson1DeleteDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.workdocs#ConcurrentModificationException": @@ -2387,10 +2398,12 @@ const deserializeAws_restJson1DeleteDocumentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2419,8 +2432,7 @@ const deserializeAws_restJson1DeleteFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.workdocs#ConcurrentModificationException": @@ -2448,10 +2460,12 @@ const deserializeAws_restJson1DeleteFolderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2480,8 +2494,7 @@ const deserializeAws_restJson1DeleteFolderContentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConflictingOperationException": case "com.amazonaws.workdocs#ConflictingOperationException": @@ -2506,10 +2519,12 @@ const deserializeAws_restJson1DeleteFolderContentsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2538,8 +2553,7 @@ const deserializeAws_restJson1DeleteLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2558,10 +2572,12 @@ const deserializeAws_restJson1DeleteLabelsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2590,8 +2606,7 @@ const deserializeAws_restJson1DeleteNotificationSubscriptionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2607,10 +2622,12 @@ const deserializeAws_restJson1DeleteNotificationSubscriptionCommandError = async throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2639,8 +2656,7 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2659,10 +2675,12 @@ const deserializeAws_restJson1DeleteUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2699,8 +2717,7 @@ const deserializeAws_restJson1DescribeActivitiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -2719,10 +2736,12 @@ const deserializeAws_restJson1DescribeActivitiesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2759,8 +2778,7 @@ const deserializeAws_restJson1DescribeCommentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2782,10 +2800,12 @@ const deserializeAws_restJson1DescribeCommentsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2822,8 +2842,7 @@ const deserializeAws_restJson1DescribeDocumentVersionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2848,10 +2867,12 @@ const deserializeAws_restJson1DescribeDocumentVersionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2892,8 +2913,7 @@ const deserializeAws_restJson1DescribeFolderContentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -2915,10 +2935,12 @@ const deserializeAws_restJson1DescribeFolderContentsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2955,8 +2977,7 @@ const deserializeAws_restJson1DescribeGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -2972,10 +2993,12 @@ const deserializeAws_restJson1DescribeGroupsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3012,8 +3035,7 @@ const deserializeAws_restJson1DescribeNotificationSubscriptionsCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3026,10 +3048,12 @@ const deserializeAws_restJson1DescribeNotificationSubscriptionsCommandError = as throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3066,8 +3090,7 @@ const deserializeAws_restJson1DescribeResourcePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -3083,10 +3106,12 @@ const deserializeAws_restJson1DescribeResourcePermissionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3123,8 +3148,7 @@ const deserializeAws_restJson1DescribeRootFoldersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -3143,10 +3167,12 @@ const deserializeAws_restJson1DescribeRootFoldersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3187,8 +3213,7 @@ const deserializeAws_restJson1DescribeUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3213,10 +3238,12 @@ const deserializeAws_restJson1DescribeUsersCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3249,8 +3276,7 @@ const deserializeAws_restJson1GetCurrentUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3269,10 +3295,12 @@ const deserializeAws_restJson1GetCurrentUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3309,8 +3337,7 @@ const deserializeAws_restJson1GetDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3335,10 +3362,12 @@ const deserializeAws_restJson1GetDocumentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3371,8 +3400,7 @@ const deserializeAws_restJson1GetDocumentPathCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3391,10 +3419,12 @@ const deserializeAws_restJson1GetDocumentPathCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3431,8 +3461,7 @@ const deserializeAws_restJson1GetDocumentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3457,10 +3486,12 @@ const deserializeAws_restJson1GetDocumentVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3497,8 +3528,7 @@ const deserializeAws_restJson1GetFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3523,10 +3553,12 @@ const deserializeAws_restJson1GetFolderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3559,8 +3591,7 @@ const deserializeAws_restJson1GetFolderPathCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotExistsException": case "com.amazonaws.workdocs#EntityNotExistsException": @@ -3579,10 +3610,12 @@ const deserializeAws_restJson1GetFolderPathCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3623,8 +3656,7 @@ const deserializeAws_restJson1GetResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -3643,10 +3675,12 @@ const deserializeAws_restJson1GetResourcesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3683,8 +3717,7 @@ const deserializeAws_restJson1InitiateDocumentVersionUploadCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DraftUploadOutOfSyncException": case "com.amazonaws.workdocs#DraftUploadOutOfSyncException": @@ -3721,10 +3754,12 @@ const deserializeAws_restJson1InitiateDocumentVersionUploadCommandError = async throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3753,8 +3788,7 @@ const deserializeAws_restJson1RemoveAllResourcePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -3770,10 +3804,12 @@ const deserializeAws_restJson1RemoveAllResourcePermissionsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3802,8 +3838,7 @@ const deserializeAws_restJson1RemoveResourcePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "FailedDependencyException": case "com.amazonaws.workdocs#FailedDependencyException": @@ -3819,10 +3854,12 @@ const deserializeAws_restJson1RemoveResourcePermissionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3851,8 +3888,7 @@ const deserializeAws_restJson1UpdateDocumentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.workdocs#ConcurrentModificationException": @@ -3886,10 +3922,12 @@ const deserializeAws_restJson1UpdateDocumentCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3918,8 +3956,7 @@ const deserializeAws_restJson1UpdateDocumentVersionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.workdocs#ConcurrentModificationException": @@ -3947,10 +3984,12 @@ const deserializeAws_restJson1UpdateDocumentVersionCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3979,8 +4018,7 @@ const deserializeAws_restJson1UpdateFolderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ConcurrentModificationException": case "com.amazonaws.workdocs#ConcurrentModificationException": @@ -4014,10 +4052,12 @@ const deserializeAws_restJson1UpdateFolderCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4050,8 +4090,7 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DeactivatingLastSystemUserException": case "com.amazonaws.workdocs#DeactivatingLastSystemUserException": @@ -4079,10 +4118,12 @@ const deserializeAws_restJson1UpdateUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedResourceAccessExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5145,7 +5186,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -5171,6 +5212,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-worklink/src/protocols/Aws_restJson1.ts b/clients/client-worklink/src/protocols/Aws_restJson1.ts index b73a6c2e4b97b..7f9fe3b4eb1af 100644 --- a/clients/client-worklink/src/protocols/Aws_restJson1.ts +++ b/clients/client-worklink/src/protocols/Aws_restJson1.ts @@ -1029,8 +1029,7 @@ const deserializeAws_restJson1AssociateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1052,10 +1051,12 @@ const deserializeAws_restJson1AssociateDomainCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1088,8 +1089,7 @@ const deserializeAws_restJson1AssociateWebsiteAuthorizationProviderCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1111,10 +1111,12 @@ const deserializeAws_restJson1AssociateWebsiteAuthorizationProviderCommandError throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1147,8 +1149,7 @@ const deserializeAws_restJson1AssociateWebsiteCertificateAuthorityCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1170,10 +1171,12 @@ const deserializeAws_restJson1AssociateWebsiteCertificateAuthorityCommandError = throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1206,8 +1209,7 @@ const deserializeAws_restJson1CreateFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1229,10 +1231,12 @@ const deserializeAws_restJson1CreateFleetCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1261,8 +1265,7 @@ const deserializeAws_restJson1DeleteFleetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1281,10 +1284,12 @@ const deserializeAws_restJson1DeleteFleetCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1317,8 +1322,7 @@ const deserializeAws_restJson1DescribeAuditStreamConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1337,10 +1341,12 @@ const deserializeAws_restJson1DescribeAuditStreamConfigurationCommandError = asy throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1381,8 +1387,7 @@ const deserializeAws_restJson1DescribeCompanyNetworkConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1401,10 +1406,12 @@ const deserializeAws_restJson1DescribeCompanyNetworkConfigurationCommandError = throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1469,8 +1476,7 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1489,10 +1495,12 @@ const deserializeAws_restJson1DescribeDeviceCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1525,8 +1533,7 @@ const deserializeAws_restJson1DescribeDevicePolicyConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1545,10 +1552,12 @@ const deserializeAws_restJson1DescribeDevicePolicyConfigurationCommandError = as throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1597,8 +1606,7 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1617,10 +1625,12 @@ const deserializeAws_restJson1DescribeDomainCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1681,8 +1691,7 @@ const deserializeAws_restJson1DescribeFleetMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1701,10 +1710,12 @@ const deserializeAws_restJson1DescribeFleetMetadataCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1745,8 +1756,7 @@ const deserializeAws_restJson1DescribeIdentityProviderConfigurationCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1765,10 +1775,12 @@ const deserializeAws_restJson1DescribeIdentityProviderConfigurationCommandError throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1809,8 +1821,7 @@ const deserializeAws_restJson1DescribeWebsiteCertificateAuthorityCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1829,10 +1840,12 @@ const deserializeAws_restJson1DescribeWebsiteCertificateAuthorityCommandError = throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1861,8 +1874,7 @@ const deserializeAws_restJson1DisassociateDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1881,10 +1893,12 @@ const deserializeAws_restJson1DisassociateDomainCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1927,7 @@ const deserializeAws_restJson1DisassociateWebsiteAuthorizationProviderCommandErr body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1936,10 +1949,12 @@ const deserializeAws_restJson1DisassociateWebsiteAuthorizationProviderCommandErr throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1968,8 +1983,7 @@ const deserializeAws_restJson1DisassociateWebsiteCertificateAuthorityCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -1988,10 +2002,12 @@ const deserializeAws_restJson1DisassociateWebsiteCertificateAuthorityCommandErro throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2028,8 +2044,7 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2048,10 +2063,12 @@ const deserializeAws_restJson1ListDevicesCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2088,8 +2105,7 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2108,10 +2124,12 @@ const deserializeAws_restJson1ListDomainsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2148,8 +2166,7 @@ const deserializeAws_restJson1ListFleetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2165,10 +2182,12 @@ const deserializeAws_restJson1ListFleetsCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2201,18 +2220,19 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.worklink#InvalidRequestException": throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2252,8 +2272,7 @@ const deserializeAws_restJson1ListWebsiteAuthorizationProvidersCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2272,10 +2291,12 @@ const deserializeAws_restJson1ListWebsiteAuthorizationProvidersCommandError = as throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2315,8 +2336,7 @@ const deserializeAws_restJson1ListWebsiteCertificateAuthoritiesCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2332,10 +2352,12 @@ const deserializeAws_restJson1ListWebsiteCertificateAuthoritiesCommandError = as throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2364,8 +2386,7 @@ const deserializeAws_restJson1RestoreDomainAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2384,10 +2405,12 @@ const deserializeAws_restJson1RestoreDomainAccessCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2416,8 +2439,7 @@ const deserializeAws_restJson1RevokeDomainAccessCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2436,10 +2458,12 @@ const deserializeAws_restJson1RevokeDomainAccessCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2468,8 +2492,7 @@ const deserializeAws_restJson1SignOutUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2488,10 +2511,12 @@ const deserializeAws_restJson1SignOutUserCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2520,18 +2545,19 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.worklink#InvalidRequestException": throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2560,18 +2586,19 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.worklink#InvalidRequestException": throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2600,8 +2627,7 @@ const deserializeAws_restJson1UpdateAuditStreamConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2620,10 +2646,12 @@ const deserializeAws_restJson1UpdateAuditStreamConfigurationCommandError = async throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2652,8 +2680,7 @@ const deserializeAws_restJson1UpdateCompanyNetworkConfigurationCommandError = as body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2672,10 +2699,12 @@ const deserializeAws_restJson1UpdateCompanyNetworkConfigurationCommandError = as throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2704,8 +2733,7 @@ const deserializeAws_restJson1UpdateDevicePolicyConfigurationCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2724,10 +2752,12 @@ const deserializeAws_restJson1UpdateDevicePolicyConfigurationCommandError = asyn throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2756,8 +2786,7 @@ const deserializeAws_restJson1UpdateDomainMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2776,10 +2805,12 @@ const deserializeAws_restJson1UpdateDomainMetadataCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2808,8 +2839,7 @@ const deserializeAws_restJson1UpdateFleetMetadataCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2828,10 +2858,12 @@ const deserializeAws_restJson1UpdateFleetMetadataCommandError = async ( throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2860,8 +2892,7 @@ const deserializeAws_restJson1UpdateIdentityProviderConfigurationCommandError = body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InternalServerErrorException": case "com.amazonaws.worklink#InternalServerErrorException": @@ -2880,10 +2911,12 @@ const deserializeAws_restJson1UpdateIdentityProviderConfigurationCommandError = throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3222,7 +3255,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3248,6 +3281,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-workmail/src/protocols/Aws_json1_1.ts b/clients/client-workmail/src/protocols/Aws_json1_1.ts index a0446ad3ae366..9567322a5e4e7 100644 --- a/clients/client-workmail/src/protocols/Aws_json1_1.ts +++ b/clients/client-workmail/src/protocols/Aws_json1_1.ts @@ -1291,8 +1291,7 @@ const deserializeAws_json1_1AssociateDelegateToResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -1311,10 +1310,12 @@ const deserializeAws_json1_1AssociateDelegateToResourceCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1346,8 +1347,7 @@ const deserializeAws_json1_1AssociateMemberToGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -1375,10 +1375,12 @@ const deserializeAws_json1_1AssociateMemberToGroupCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1410,8 +1412,7 @@ const deserializeAws_json1_1CancelMailboxExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -1427,10 +1428,12 @@ const deserializeAws_json1_1CancelMailboxExportJobCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1462,8 +1465,7 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EmailAddressInUseException": case "com.amazonaws.workmail#EmailAddressInUseException": @@ -1494,10 +1496,12 @@ const deserializeAws_json1_1CreateAliasCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1529,8 +1533,7 @@ const deserializeAws_json1_1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -1558,10 +1561,12 @@ const deserializeAws_json1_1CreateGroupCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1593,8 +1598,7 @@ const deserializeAws_json1_1CreateMobileDeviceAccessRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -1610,10 +1614,12 @@ const deserializeAws_json1_1CreateMobileDeviceAccessRuleCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1645,8 +1651,7 @@ const deserializeAws_json1_1CreateOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryInUseException": case "com.amazonaws.workmail#DirectoryInUseException": @@ -1665,10 +1670,12 @@ const deserializeAws_json1_1CreateOrganizationCommandError = async ( throw await deserializeAws_json1_1NameAvailabilityExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1700,8 +1707,7 @@ const deserializeAws_json1_1CreateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -1726,10 +1732,12 @@ const deserializeAws_json1_1CreateResourceCommandError = async ( throw await deserializeAws_json1_1ReservedNameExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1761,8 +1769,7 @@ const deserializeAws_json1_1CreateUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -1793,10 +1800,12 @@ const deserializeAws_json1_1CreateUserCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1828,8 +1837,7 @@ const deserializeAws_json1_1DeleteAccessControlRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OrganizationNotFoundException": case "com.amazonaws.workmail#OrganizationNotFoundException": @@ -1839,10 +1847,12 @@ const deserializeAws_json1_1DeleteAccessControlRuleCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1874,8 +1884,7 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -1894,10 +1903,12 @@ const deserializeAws_json1_1DeleteAliasCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1929,8 +1940,7 @@ const deserializeAws_json1_1DeleteEmailMonitoringConfigurationCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -1943,10 +1953,12 @@ const deserializeAws_json1_1DeleteEmailMonitoringConfigurationCommandError = asy throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1978,8 +1990,7 @@ const deserializeAws_json1_1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -2004,10 +2015,12 @@ const deserializeAws_json1_1DeleteGroupCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2039,8 +2052,7 @@ const deserializeAws_json1_1DeleteMailboxPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2059,10 +2071,12 @@ const deserializeAws_json1_1DeleteMailboxPermissionsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2094,8 +2108,7 @@ const deserializeAws_json1_1DeleteMobileDeviceAccessOverrideCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2111,10 +2124,12 @@ const deserializeAws_json1_1DeleteMobileDeviceAccessOverrideCommandError = async throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2146,8 +2161,7 @@ const deserializeAws_json1_1DeleteMobileDeviceAccessRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -2160,10 +2174,12 @@ const deserializeAws_json1_1DeleteMobileDeviceAccessRuleCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2195,8 +2211,7 @@ const deserializeAws_json1_1DeleteOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -2209,10 +2224,12 @@ const deserializeAws_json1_1DeleteOrganizationCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2244,8 +2261,7 @@ const deserializeAws_json1_1DeleteResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityStateException": case "com.amazonaws.workmail#EntityStateException": @@ -2261,10 +2277,12 @@ const deserializeAws_json1_1DeleteResourceCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2296,8 +2314,7 @@ const deserializeAws_json1_1DeleteRetentionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -2310,10 +2327,12 @@ const deserializeAws_json1_1DeleteRetentionPolicyCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2345,8 +2364,7 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -2371,10 +2389,12 @@ const deserializeAws_json1_1DeleteUserCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2406,8 +2426,7 @@ const deserializeAws_json1_1DeregisterFromWorkMailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2426,10 +2445,12 @@ const deserializeAws_json1_1DeregisterFromWorkMailCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2461,8 +2482,7 @@ const deserializeAws_json1_1DeregisterMailDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidCustomSesConfigurationException": case "com.amazonaws.workmail#InvalidCustomSesConfigurationException": @@ -2481,10 +2501,12 @@ const deserializeAws_json1_1DeregisterMailDomainCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2516,8 +2538,7 @@ const deserializeAws_json1_1DescribeEmailMonitoringConfigurationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -2533,10 +2554,12 @@ const deserializeAws_json1_1DescribeEmailMonitoringConfigurationCommandError = a throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2568,8 +2591,7 @@ const deserializeAws_json1_1DescribeGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2585,10 +2607,12 @@ const deserializeAws_json1_1DescribeGroupCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2620,8 +2644,7 @@ const deserializeAws_json1_1DescribeInboundDmarcSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OrganizationNotFoundException": case "com.amazonaws.workmail#OrganizationNotFoundException": @@ -2631,10 +2654,12 @@ const deserializeAws_json1_1DescribeInboundDmarcSettingsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2666,8 +2691,7 @@ const deserializeAws_json1_1DescribeMailboxExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2683,10 +2707,12 @@ const deserializeAws_json1_1DescribeMailboxExportJobCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2718,8 +2744,7 @@ const deserializeAws_json1_1DescribeOrganizationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -2729,10 +2754,12 @@ const deserializeAws_json1_1DescribeOrganizationCommandError = async ( throw await deserializeAws_json1_1OrganizationNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2764,8 +2791,7 @@ const deserializeAws_json1_1DescribeResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2781,10 +2807,12 @@ const deserializeAws_json1_1DescribeResourceCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2816,8 +2844,7 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2833,10 +2860,12 @@ const deserializeAws_json1_1DescribeUserCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2868,8 +2897,7 @@ const deserializeAws_json1_1DisassociateDelegateFromResourceCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -2888,10 +2916,12 @@ const deserializeAws_json1_1DisassociateDelegateFromResourceCommandError = async throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2923,8 +2953,7 @@ const deserializeAws_json1_1DisassociateMemberFromGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -2952,10 +2981,12 @@ const deserializeAws_json1_1DisassociateMemberFromGroupCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2987,8 +3018,7 @@ const deserializeAws_json1_1GetAccessControlEffectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3004,10 +3034,12 @@ const deserializeAws_json1_1GetAccessControlEffectCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3039,8 +3071,7 @@ const deserializeAws_json1_1GetDefaultRetentionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3056,10 +3087,12 @@ const deserializeAws_json1_1GetDefaultRetentionPolicyCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3091,8 +3124,7 @@ const deserializeAws_json1_1GetMailboxDetailsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3105,10 +3137,12 @@ const deserializeAws_json1_1GetMailboxDetailsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3140,8 +3174,7 @@ const deserializeAws_json1_1GetMailDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3157,10 +3190,12 @@ const deserializeAws_json1_1GetMailDomainCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3192,8 +3227,7 @@ const deserializeAws_json1_1GetMobileDeviceAccessEffectCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3206,10 +3240,12 @@ const deserializeAws_json1_1GetMobileDeviceAccessEffectCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3241,8 +3277,7 @@ const deserializeAws_json1_1GetMobileDeviceAccessOverrideCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3261,10 +3296,12 @@ const deserializeAws_json1_1GetMobileDeviceAccessOverrideCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3296,8 +3333,7 @@ const deserializeAws_json1_1ListAccessControlRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OrganizationNotFoundException": case "com.amazonaws.workmail#OrganizationNotFoundException": @@ -3307,10 +3343,12 @@ const deserializeAws_json1_1ListAccessControlRulesCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3342,8 +3380,7 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3362,10 +3399,12 @@ const deserializeAws_json1_1ListAliasesCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3397,8 +3436,7 @@ const deserializeAws_json1_1ListGroupMembersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3417,10 +3455,12 @@ const deserializeAws_json1_1ListGroupMembersCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3452,8 +3492,7 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3469,10 +3508,12 @@ const deserializeAws_json1_1ListGroupsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3504,8 +3545,7 @@ const deserializeAws_json1_1ListMailboxExportJobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3518,10 +3558,12 @@ const deserializeAws_json1_1ListMailboxExportJobsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3553,8 +3595,7 @@ const deserializeAws_json1_1ListMailboxPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3570,10 +3611,12 @@ const deserializeAws_json1_1ListMailboxPermissionsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3605,8 +3648,7 @@ const deserializeAws_json1_1ListMailDomainsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3619,10 +3661,12 @@ const deserializeAws_json1_1ListMailDomainsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3654,8 +3698,7 @@ const deserializeAws_json1_1ListMobileDeviceAccessOverridesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3671,10 +3714,12 @@ const deserializeAws_json1_1ListMobileDeviceAccessOverridesCommandError = async throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3706,8 +3751,7 @@ const deserializeAws_json1_1ListMobileDeviceAccessRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3720,10 +3764,12 @@ const deserializeAws_json1_1ListMobileDeviceAccessRulesCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3755,18 +3801,19 @@ const deserializeAws_json1_1ListOrganizationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": throw await deserializeAws_json1_1InvalidParameterExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3798,8 +3845,7 @@ const deserializeAws_json1_1ListResourceDelegatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -3818,10 +3864,12 @@ const deserializeAws_json1_1ListResourceDelegatesCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3853,8 +3901,7 @@ const deserializeAws_json1_1ListResourcesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3867,10 +3914,12 @@ const deserializeAws_json1_1ListResourcesCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3902,18 +3951,19 @@ const deserializeAws_json1_1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.workmail#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3945,8 +3995,7 @@ const deserializeAws_json1_1ListUsersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -3959,10 +4008,12 @@ const deserializeAws_json1_1ListUsersCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3994,8 +4045,7 @@ const deserializeAws_json1_1PutAccessControlRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4014,10 +4064,12 @@ const deserializeAws_json1_1PutAccessControlRuleCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4049,8 +4101,7 @@ const deserializeAws_json1_1PutEmailMonitoringConfigurationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -4066,10 +4117,12 @@ const deserializeAws_json1_1PutEmailMonitoringConfigurationCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4101,8 +4154,7 @@ const deserializeAws_json1_1PutInboundDmarcSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OrganizationNotFoundException": case "com.amazonaws.workmail#OrganizationNotFoundException": @@ -4112,10 +4164,12 @@ const deserializeAws_json1_1PutInboundDmarcSettingsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4147,8 +4201,7 @@ const deserializeAws_json1_1PutMailboxPermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4167,10 +4220,12 @@ const deserializeAws_json1_1PutMailboxPermissionsCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4202,8 +4257,7 @@ const deserializeAws_json1_1PutMobileDeviceAccessOverrideCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4222,10 +4276,12 @@ const deserializeAws_json1_1PutMobileDeviceAccessOverrideCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4257,8 +4313,7 @@ const deserializeAws_json1_1PutRetentionPolicyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -4274,10 +4329,12 @@ const deserializeAws_json1_1PutRetentionPolicyCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4309,8 +4366,7 @@ const deserializeAws_json1_1RegisterMailDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -4329,10 +4385,12 @@ const deserializeAws_json1_1RegisterMailDomainCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4364,8 +4422,7 @@ const deserializeAws_json1_1RegisterToWorkMailCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -4402,10 +4459,12 @@ const deserializeAws_json1_1RegisterToWorkMailCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4437,8 +4496,7 @@ const deserializeAws_json1_1ResetPasswordCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -4469,10 +4527,12 @@ const deserializeAws_json1_1ResetPasswordCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4504,8 +4564,7 @@ const deserializeAws_json1_1StartMailboxExportJobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4524,10 +4583,12 @@ const deserializeAws_json1_1StartMailboxExportJobCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4559,8 +4620,7 @@ const deserializeAws_json1_1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "OrganizationStateException": case "com.amazonaws.workmail#OrganizationStateException": @@ -4573,10 +4633,12 @@ const deserializeAws_json1_1TagResourceCommandError = async ( throw await deserializeAws_json1_1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4608,18 +4670,19 @@ const deserializeAws_json1_1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.workmail#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4651,8 +4714,7 @@ const deserializeAws_json1_1UpdateDefaultMailDomainCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterException": case "com.amazonaws.workmail#InvalidParameterException": @@ -4671,10 +4733,12 @@ const deserializeAws_json1_1UpdateDefaultMailDomainCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4706,8 +4770,7 @@ const deserializeAws_json1_1UpdateMailboxQuotaCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4726,10 +4789,12 @@ const deserializeAws_json1_1UpdateMailboxQuotaCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4761,8 +4826,7 @@ const deserializeAws_json1_1UpdateMobileDeviceAccessRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "EntityNotFoundException": case "com.amazonaws.workmail#EntityNotFoundException": @@ -4778,10 +4842,12 @@ const deserializeAws_json1_1UpdateMobileDeviceAccessRuleCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4813,8 +4879,7 @@ const deserializeAws_json1_1UpdatePrimaryEmailAddressCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryServiceAuthenticationFailedException": case "com.amazonaws.workmail#DirectoryServiceAuthenticationFailedException": @@ -4851,10 +4916,12 @@ const deserializeAws_json1_1UpdatePrimaryEmailAddressCommandError = async ( throw await deserializeAws_json1_1UnsupportedOperationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4886,8 +4953,7 @@ const deserializeAws_json1_1UpdateResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "DirectoryUnavailableException": case "com.amazonaws.workmail#DirectoryUnavailableException": @@ -4921,10 +4987,12 @@ const deserializeAws_json1_1UpdateResourceCommandError = async ( throw await deserializeAws_json1_1OrganizationStateExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7697,7 +7765,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7723,6 +7791,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts b/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts index d2505f8ce425c..ca5a6add8ef8b 100644 --- a/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts +++ b/clients/client-workmailmessageflow/src/protocols/Aws_restJson1.ts @@ -116,18 +116,19 @@ const deserializeAws_restJson1GetRawMessageContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.workmailmessageflow#ResourceNotFoundException": throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -156,8 +157,7 @@ const deserializeAws_restJson1PutRawMessageContentCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidContentLocation": case "com.amazonaws.workmailmessageflow#InvalidContentLocation": @@ -173,10 +173,12 @@ const deserializeAws_restJson1PutRawMessageContentCommandError = async ( throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -298,7 +300,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -324,6 +326,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-workspaces-web/src/protocols/Aws_restJson1.ts b/clients/client-workspaces-web/src/protocols/Aws_restJson1.ts index 98fe7095062cf..51fee32844f15 100644 --- a/clients/client-workspaces-web/src/protocols/Aws_restJson1.ts +++ b/clients/client-workspaces-web/src/protocols/Aws_restJson1.ts @@ -1778,8 +1778,7 @@ const deserializeAws_restJson1AssociateBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -1801,10 +1800,12 @@ const deserializeAws_restJson1AssociateBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1841,8 +1842,7 @@ const deserializeAws_restJson1AssociateNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -1864,10 +1864,12 @@ const deserializeAws_restJson1AssociateNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1904,8 +1906,7 @@ const deserializeAws_restJson1AssociateTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -1924,10 +1925,12 @@ const deserializeAws_restJson1AssociateTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1964,8 +1967,7 @@ const deserializeAws_restJson1AssociateUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -1987,10 +1989,12 @@ const deserializeAws_restJson1AssociateUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2023,8 +2027,7 @@ const deserializeAws_restJson1CreateBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2049,10 +2052,12 @@ const deserializeAws_restJson1CreateBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2085,8 +2090,7 @@ const deserializeAws_restJson1CreateIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2111,10 +2115,12 @@ const deserializeAws_restJson1CreateIdentityProviderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2147,8 +2153,7 @@ const deserializeAws_restJson1CreateNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2170,10 +2175,12 @@ const deserializeAws_restJson1CreateNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2210,8 +2217,7 @@ const deserializeAws_restJson1CreatePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2236,10 +2242,12 @@ const deserializeAws_restJson1CreatePortalCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2272,8 +2280,7 @@ const deserializeAws_restJson1CreateTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2295,10 +2302,12 @@ const deserializeAws_restJson1CreateTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2331,8 +2340,7 @@ const deserializeAws_restJson1CreateUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2354,10 +2362,12 @@ const deserializeAws_restJson1CreateUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2386,8 +2396,7 @@ const deserializeAws_restJson1DeleteBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2406,10 +2415,12 @@ const deserializeAws_restJson1DeleteBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2438,8 +2449,7 @@ const deserializeAws_restJson1DeleteIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2458,10 +2468,12 @@ const deserializeAws_restJson1DeleteIdentityProviderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2490,8 +2502,7 @@ const deserializeAws_restJson1DeleteNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2510,10 +2521,12 @@ const deserializeAws_restJson1DeleteNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2542,8 +2555,7 @@ const deserializeAws_restJson1DeletePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2562,10 +2574,12 @@ const deserializeAws_restJson1DeletePortalCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2594,8 +2608,7 @@ const deserializeAws_restJson1DeleteTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2614,10 +2627,12 @@ const deserializeAws_restJson1DeleteTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2646,8 +2661,7 @@ const deserializeAws_restJson1DeleteUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2666,10 +2680,12 @@ const deserializeAws_restJson1DeleteUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2698,8 +2714,7 @@ const deserializeAws_restJson1DisassociateBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2718,10 +2733,12 @@ const deserializeAws_restJson1DisassociateBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2750,8 +2767,7 @@ const deserializeAws_restJson1DisassociateNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2770,10 +2786,12 @@ const deserializeAws_restJson1DisassociateNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2802,8 +2820,7 @@ const deserializeAws_restJson1DisassociateTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2822,10 +2839,12 @@ const deserializeAws_restJson1DisassociateTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2854,8 +2873,7 @@ const deserializeAws_restJson1DisassociateUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2874,10 +2892,12 @@ const deserializeAws_restJson1DisassociateUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2910,8 +2930,7 @@ const deserializeAws_restJson1GetBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2930,10 +2949,12 @@ const deserializeAws_restJson1GetBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2966,8 +2987,7 @@ const deserializeAws_restJson1GetIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -2986,10 +3006,12 @@ const deserializeAws_restJson1GetIdentityProviderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3022,8 +3044,7 @@ const deserializeAws_restJson1GetNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3042,10 +3063,12 @@ const deserializeAws_restJson1GetNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3078,8 +3101,7 @@ const deserializeAws_restJson1GetPortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3098,10 +3120,12 @@ const deserializeAws_restJson1GetPortalCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3138,8 +3162,7 @@ const deserializeAws_restJson1GetPortalServiceProviderMetadataCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3158,10 +3181,12 @@ const deserializeAws_restJson1GetPortalServiceProviderMetadataCommandError = asy throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3194,8 +3219,7 @@ const deserializeAws_restJson1GetTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3214,10 +3238,12 @@ const deserializeAws_restJson1GetTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3254,8 +3280,7 @@ const deserializeAws_restJson1GetTrustStoreCertificateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3274,10 +3299,12 @@ const deserializeAws_restJson1GetTrustStoreCertificateCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3310,8 +3337,7 @@ const deserializeAws_restJson1GetUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3330,10 +3356,12 @@ const deserializeAws_restJson1GetUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3370,8 +3398,7 @@ const deserializeAws_restJson1ListBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3387,10 +3414,12 @@ const deserializeAws_restJson1ListBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3427,8 +3456,7 @@ const deserializeAws_restJson1ListIdentityProvidersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3444,10 +3472,12 @@ const deserializeAws_restJson1ListIdentityProvidersCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3484,8 +3514,7 @@ const deserializeAws_restJson1ListNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3501,10 +3530,12 @@ const deserializeAws_restJson1ListNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3541,8 +3572,7 @@ const deserializeAws_restJson1ListPortalsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3558,10 +3588,12 @@ const deserializeAws_restJson1ListPortalsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3594,8 +3626,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3614,10 +3645,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3658,8 +3691,7 @@ const deserializeAws_restJson1ListTrustStoreCertificatesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3678,10 +3710,12 @@ const deserializeAws_restJson1ListTrustStoreCertificatesCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3718,8 +3752,7 @@ const deserializeAws_restJson1ListTrustStoresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3735,10 +3768,12 @@ const deserializeAws_restJson1ListTrustStoresCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3775,8 +3810,7 @@ const deserializeAws_restJson1ListUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3792,10 +3826,12 @@ const deserializeAws_restJson1ListUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3824,8 +3860,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3847,10 +3882,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3879,8 +3916,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3899,10 +3935,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3935,8 +3973,7 @@ const deserializeAws_restJson1UpdateBrowserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -3955,10 +3992,12 @@ const deserializeAws_restJson1UpdateBrowserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3991,8 +4030,7 @@ const deserializeAws_restJson1UpdateIdentityProviderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -4011,10 +4049,12 @@ const deserializeAws_restJson1UpdateIdentityProviderCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4047,8 +4087,7 @@ const deserializeAws_restJson1UpdateNetworkSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -4067,10 +4106,12 @@ const deserializeAws_restJson1UpdateNetworkSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4103,8 +4144,7 @@ const deserializeAws_restJson1UpdatePortalCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -4123,10 +4163,12 @@ const deserializeAws_restJson1UpdatePortalCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4159,8 +4201,7 @@ const deserializeAws_restJson1UpdateTrustStoreCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -4182,10 +4223,12 @@ const deserializeAws_restJson1UpdateTrustStoreCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4218,8 +4261,7 @@ const deserializeAws_restJson1UpdateUserSettingsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspacesweb#AccessDeniedException": @@ -4238,10 +4280,12 @@ const deserializeAws_restJson1UpdateUserSettingsCommandError = async ( throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4921,7 +4965,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -4947,6 +4991,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-workspaces/src/protocols/Aws_json1_1.ts b/clients/client-workspaces/src/protocols/Aws_json1_1.ts index f03b325a7e89d..ff7a9372c035e 100644 --- a/clients/client-workspaces/src/protocols/Aws_json1_1.ts +++ b/clients/client-workspaces/src/protocols/Aws_json1_1.ts @@ -1201,8 +1201,7 @@ const deserializeAws_json1_1AssociateConnectionAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1224,10 +1223,12 @@ const deserializeAws_json1_1AssociateConnectionAliasCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1259,8 +1260,7 @@ const deserializeAws_json1_1AssociateIpGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1282,10 +1282,12 @@ const deserializeAws_json1_1AssociateIpGroupsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1317,8 +1319,7 @@ const deserializeAws_json1_1AuthorizeIpRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1337,10 +1338,12 @@ const deserializeAws_json1_1AuthorizeIpRulesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1372,8 +1375,7 @@ const deserializeAws_json1_1CopyWorkspaceImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1398,10 +1400,12 @@ const deserializeAws_json1_1CopyWorkspaceImageCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1433,8 +1437,7 @@ const deserializeAws_json1_1CreateConnectClientAddInCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1453,10 +1456,12 @@ const deserializeAws_json1_1CreateConnectClientAddInCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1488,8 +1493,7 @@ const deserializeAws_json1_1CreateConnectionAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1511,10 +1515,12 @@ const deserializeAws_json1_1CreateConnectionAliasCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1546,8 +1552,7 @@ const deserializeAws_json1_1CreateIpGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1566,10 +1571,12 @@ const deserializeAws_json1_1CreateIpGroupCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1601,8 +1608,7 @@ const deserializeAws_json1_1CreateTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": @@ -1615,10 +1621,12 @@ const deserializeAws_json1_1CreateTagsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1650,8 +1658,7 @@ const deserializeAws_json1_1CreateUpdatedWorkspaceImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1676,10 +1683,12 @@ const deserializeAws_json1_1CreateUpdatedWorkspaceImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1711,8 +1720,7 @@ const deserializeAws_json1_1CreateWorkspaceBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1734,10 +1742,12 @@ const deserializeAws_json1_1CreateWorkspaceBundleCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1769,8 +1779,7 @@ const deserializeAws_json1_1CreateWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": @@ -1780,10 +1789,12 @@ const deserializeAws_json1_1CreateWorkspacesCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1815,8 +1826,7 @@ const deserializeAws_json1_1DeleteClientBrandingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1829,10 +1839,12 @@ const deserializeAws_json1_1DeleteClientBrandingCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1864,8 +1876,7 @@ const deserializeAws_json1_1DeleteConnectClientAddInCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1878,10 +1889,12 @@ const deserializeAws_json1_1DeleteConnectClientAddInCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1926,7 @@ const deserializeAws_json1_1DeleteConnectionAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1936,10 +1948,12 @@ const deserializeAws_json1_1DeleteConnectionAliasCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1971,8 +1985,7 @@ const deserializeAws_json1_1DeleteIpGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -1988,10 +2001,12 @@ const deserializeAws_json1_1DeleteIpGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2023,8 +2038,7 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": @@ -2034,10 +2048,12 @@ const deserializeAws_json1_1DeleteTagsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2069,8 +2085,7 @@ const deserializeAws_json1_1DeleteWorkspaceBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2086,10 +2101,12 @@ const deserializeAws_json1_1DeleteWorkspaceBundleCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2121,8 +2138,7 @@ const deserializeAws_json1_1DeleteWorkspaceImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2135,10 +2151,12 @@ const deserializeAws_json1_1DeleteWorkspaceImageCommandError = async ( throw await deserializeAws_json1_1ResourceAssociatedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2170,8 +2188,7 @@ const deserializeAws_json1_1DeregisterWorkspaceDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2190,10 +2207,12 @@ const deserializeAws_json1_1DeregisterWorkspaceDirectoryCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2225,18 +2244,19 @@ const deserializeAws_json1_1DescribeAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": throw await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2268,18 +2288,19 @@ const deserializeAws_json1_1DescribeAccountModificationsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": throw await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2311,8 +2332,7 @@ const deserializeAws_json1_1DescribeClientBrandingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2325,10 +2345,12 @@ const deserializeAws_json1_1DescribeClientBrandingCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2360,8 +2382,7 @@ const deserializeAws_json1_1DescribeClientPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2374,10 +2395,12 @@ const deserializeAws_json1_1DescribeClientPropertiesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2409,8 +2432,7 @@ const deserializeAws_json1_1DescribeConnectClientAddInsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2423,10 +2445,12 @@ const deserializeAws_json1_1DescribeConnectClientAddInsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2458,8 +2482,7 @@ const deserializeAws_json1_1DescribeConnectionAliasesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2472,10 +2495,12 @@ const deserializeAws_json1_1DescribeConnectionAliasesCommandError = async ( throw await deserializeAws_json1_1OperationNotSupportedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2507,8 +2532,7 @@ const deserializeAws_json1_1DescribeConnectionAliasPermissionsCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2524,10 +2548,12 @@ const deserializeAws_json1_1DescribeConnectionAliasPermissionsCommandError = asy throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2559,8 +2585,7 @@ const deserializeAws_json1_1DescribeIpGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2570,10 +2595,12 @@ const deserializeAws_json1_1DescribeIpGroupsCommandError = async ( throw await deserializeAws_json1_1InvalidParameterValuesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2605,18 +2632,19 @@ const deserializeAws_json1_1DescribeTagsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ResourceNotFoundException": case "com.amazonaws.workspaces#ResourceNotFoundException": throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2648,18 +2676,19 @@ const deserializeAws_json1_1DescribeWorkspaceBundlesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": throw await deserializeAws_json1_1InvalidParameterValuesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2691,18 +2720,19 @@ const deserializeAws_json1_1DescribeWorkspaceDirectoriesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": throw await deserializeAws_json1_1InvalidParameterValuesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2734,8 +2764,7 @@ const deserializeAws_json1_1DescribeWorkspaceImagePermissionsCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2748,10 +2777,12 @@ const deserializeAws_json1_1DescribeWorkspaceImagePermissionsCommandError = asyn throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2783,18 +2814,19 @@ const deserializeAws_json1_1DescribeWorkspaceImagesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": throw await deserializeAws_json1_1AccessDeniedExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2826,8 +2858,7 @@ const deserializeAws_json1_1DescribeWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": @@ -2837,10 +2868,12 @@ const deserializeAws_json1_1DescribeWorkspacesCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2872,18 +2905,19 @@ const deserializeAws_json1_1DescribeWorkspacesConnectionStatusCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": throw await deserializeAws_json1_1InvalidParameterValuesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2915,8 +2949,7 @@ const deserializeAws_json1_1DescribeWorkspaceSnapshotsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2929,10 +2962,12 @@ const deserializeAws_json1_1DescribeWorkspaceSnapshotsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2964,8 +2999,7 @@ const deserializeAws_json1_1DisassociateConnectionAliasCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -2984,10 +3018,12 @@ const deserializeAws_json1_1DisassociateConnectionAliasCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3019,8 +3055,7 @@ const deserializeAws_json1_1DisassociateIpGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3036,10 +3071,12 @@ const deserializeAws_json1_1DisassociateIpGroupsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3071,8 +3108,7 @@ const deserializeAws_json1_1ImportClientBrandingCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3085,10 +3121,12 @@ const deserializeAws_json1_1ImportClientBrandingCommandError = async ( throw await deserializeAws_json1_1ResourceLimitExceededExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3120,8 +3158,7 @@ const deserializeAws_json1_1ImportWorkspaceImageCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3143,10 +3180,12 @@ const deserializeAws_json1_1ImportWorkspaceImageCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3178,8 +3217,7 @@ const deserializeAws_json1_1ListAvailableManagementCidrRangesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3189,10 +3227,12 @@ const deserializeAws_json1_1ListAvailableManagementCidrRangesCommandError = asyn throw await deserializeAws_json1_1InvalidParameterValuesExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3224,8 +3264,7 @@ const deserializeAws_json1_1MigrateWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3247,10 +3286,12 @@ const deserializeAws_json1_1MigrateWorkspaceCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3282,8 +3323,7 @@ const deserializeAws_json1_1ModifyAccountCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3302,10 +3342,12 @@ const deserializeAws_json1_1ModifyAccountCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3337,8 +3379,7 @@ const deserializeAws_json1_1ModifyClientPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3351,10 +3392,12 @@ const deserializeAws_json1_1ModifyClientPropertiesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3386,8 +3429,7 @@ const deserializeAws_json1_1ModifySelfservicePermissionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3400,10 +3442,12 @@ const deserializeAws_json1_1ModifySelfservicePermissionsCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3435,8 +3479,7 @@ const deserializeAws_json1_1ModifyWorkspaceAccessPropertiesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3446,10 +3489,12 @@ const deserializeAws_json1_1ModifyWorkspaceAccessPropertiesCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3481,8 +3526,7 @@ const deserializeAws_json1_1ModifyWorkspaceCreationPropertiesCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3498,10 +3542,12 @@ const deserializeAws_json1_1ModifyWorkspaceCreationPropertiesCommandError = asyn throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3533,8 +3579,7 @@ const deserializeAws_json1_1ModifyWorkspacePropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3559,10 +3604,12 @@ const deserializeAws_json1_1ModifyWorkspacePropertiesCommandError = async ( throw await deserializeAws_json1_1UnsupportedWorkspaceConfigurationExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3594,8 +3641,7 @@ const deserializeAws_json1_1ModifyWorkspaceStateCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidParameterValuesException": case "com.amazonaws.workspaces#InvalidParameterValuesException": @@ -3608,10 +3654,12 @@ const deserializeAws_json1_1ModifyWorkspaceStateCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3643,15 +3691,16 @@ const deserializeAws_json1_1RebootWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3683,15 +3732,16 @@ const deserializeAws_json1_1RebuildWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3723,8 +3773,7 @@ const deserializeAws_json1_1RegisterWorkspaceDirectoryCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3752,10 +3801,12 @@ const deserializeAws_json1_1RegisterWorkspaceDirectoryCommandError = async ( throw await deserializeAws_json1_1WorkspacesDefaultRoleNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3787,8 +3838,7 @@ const deserializeAws_json1_1RestoreWorkspaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3801,10 +3851,12 @@ const deserializeAws_json1_1RestoreWorkspaceCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3836,8 +3888,7 @@ const deserializeAws_json1_1RevokeIpRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -3853,10 +3904,12 @@ const deserializeAws_json1_1RevokeIpRulesCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3888,15 +3941,16 @@ const deserializeAws_json1_1StartWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3928,15 +3982,16 @@ const deserializeAws_json1_1StopWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3968,15 +4023,16 @@ const deserializeAws_json1_1TerminateWorkspacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4008,8 +4064,7 @@ const deserializeAws_json1_1UpdateConnectClientAddInCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -4022,10 +4077,12 @@ const deserializeAws_json1_1UpdateConnectClientAddInCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4057,8 +4114,7 @@ const deserializeAws_json1_1UpdateConnectionAliasPermissionCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -4083,10 +4139,12 @@ const deserializeAws_json1_1UpdateConnectionAliasPermissionCommandError = async throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4118,8 +4176,7 @@ const deserializeAws_json1_1UpdateRulesOfIpGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -4138,10 +4195,12 @@ const deserializeAws_json1_1UpdateRulesOfIpGroupCommandError = async ( throw await deserializeAws_json1_1ResourceNotFoundExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4173,8 +4232,7 @@ const deserializeAws_json1_1UpdateWorkspaceBundleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -4190,10 +4248,12 @@ const deserializeAws_json1_1UpdateWorkspaceBundleCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4225,8 +4285,7 @@ const deserializeAws_json1_1UpdateWorkspaceImagePermissionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "AccessDeniedException": case "com.amazonaws.workspaces#AccessDeniedException": @@ -4245,10 +4304,12 @@ const deserializeAws_json1_1UpdateWorkspaceImagePermissionCommandError = async ( throw await deserializeAws_json1_1ResourceUnavailableExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7115,7 +7176,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7141,6 +7202,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/clients/client-xray/src/protocols/Aws_restJson1.ts b/clients/client-xray/src/protocols/Aws_restJson1.ts index 04db641be3900..2a358da1c5f77 100644 --- a/clients/client-xray/src/protocols/Aws_restJson1.ts +++ b/clients/client-xray/src/protocols/Aws_restJson1.ts @@ -913,8 +913,7 @@ const deserializeAws_restJson1BatchGetTracesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -924,10 +923,12 @@ const deserializeAws_restJson1BatchGetTracesCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -960,8 +961,7 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -971,10 +971,12 @@ const deserializeAws_restJson1CreateGroupCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1007,8 +1009,7 @@ const deserializeAws_restJson1CreateSamplingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1021,10 +1022,12 @@ const deserializeAws_restJson1CreateSamplingRuleCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1053,8 +1056,7 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1064,10 +1066,12 @@ const deserializeAws_restJson1DeleteGroupCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1100,8 +1104,7 @@ const deserializeAws_restJson1DeleteSamplingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1111,10 +1114,12 @@ const deserializeAws_restJson1DeleteSamplingRuleCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1147,8 +1152,7 @@ const deserializeAws_restJson1GetEncryptionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1158,10 +1162,12 @@ const deserializeAws_restJson1GetEncryptionConfigCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1194,8 +1200,7 @@ const deserializeAws_restJson1GetGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1205,10 +1210,12 @@ const deserializeAws_restJson1GetGroupCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1245,8 +1252,7 @@ const deserializeAws_restJson1GetGroupsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1256,10 +1262,12 @@ const deserializeAws_restJson1GetGroupsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1292,8 +1300,7 @@ const deserializeAws_restJson1GetInsightCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1303,10 +1310,12 @@ const deserializeAws_restJson1GetInsightCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1343,8 +1352,7 @@ const deserializeAws_restJson1GetInsightEventsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1354,10 +1362,12 @@ const deserializeAws_restJson1GetInsightEventsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1414,8 +1424,7 @@ const deserializeAws_restJson1GetInsightImpactGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1425,10 +1434,12 @@ const deserializeAws_restJson1GetInsightImpactGraphCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1465,8 +1476,7 @@ const deserializeAws_restJson1GetInsightSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1476,10 +1486,12 @@ const deserializeAws_restJson1GetInsightSummariesCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1516,8 +1528,7 @@ const deserializeAws_restJson1GetSamplingRulesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1527,10 +1538,12 @@ const deserializeAws_restJson1GetSamplingRulesCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1570,8 +1583,7 @@ const deserializeAws_restJson1GetSamplingStatisticSummariesCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1581,10 +1593,12 @@ const deserializeAws_restJson1GetSamplingStatisticSummariesCommandError = async throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1631,8 +1645,7 @@ const deserializeAws_restJson1GetSamplingTargetsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1642,10 +1655,12 @@ const deserializeAws_restJson1GetSamplingTargetsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1694,8 +1709,7 @@ const deserializeAws_restJson1GetServiceGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1705,10 +1719,12 @@ const deserializeAws_restJson1GetServiceGraphCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1752,8 +1768,7 @@ const deserializeAws_restJson1GetTimeSeriesServiceStatisticsCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1763,10 +1778,12 @@ const deserializeAws_restJson1GetTimeSeriesServiceStatisticsCommandError = async throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1803,8 +1820,7 @@ const deserializeAws_restJson1GetTraceGraphCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1814,10 +1830,12 @@ const deserializeAws_restJson1GetTraceGraphCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1862,8 +1880,7 @@ const deserializeAws_restJson1GetTraceSummariesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1873,10 +1890,12 @@ const deserializeAws_restJson1GetTraceSummariesCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1913,8 +1932,7 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1927,10 +1945,12 @@ const deserializeAws_restJson1ListTagsForResourceCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1963,8 +1983,7 @@ const deserializeAws_restJson1PutEncryptionConfigCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -1974,10 +1993,12 @@ const deserializeAws_restJson1PutEncryptionConfigCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2006,8 +2027,7 @@ const deserializeAws_restJson1PutTelemetryRecordsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2017,10 +2037,12 @@ const deserializeAws_restJson1PutTelemetryRecordsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2056,8 +2078,7 @@ const deserializeAws_restJson1PutTraceSegmentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2067,10 +2088,12 @@ const deserializeAws_restJson1PutTraceSegmentsCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2099,8 +2122,7 @@ const deserializeAws_restJson1TagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2116,10 +2138,12 @@ const deserializeAws_restJson1TagResourceCommandError = async ( throw await deserializeAws_restJson1TooManyTagsExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2148,8 +2172,7 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2162,10 +2185,12 @@ const deserializeAws_restJson1UntagResourceCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2198,8 +2223,7 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2209,10 +2233,12 @@ const deserializeAws_restJson1UpdateGroupCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2245,8 +2271,7 @@ const deserializeAws_restJson1UpdateSamplingRuleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "InvalidRequestException": case "com.amazonaws.xray#InvalidRequestException": @@ -2256,10 +2281,12 @@ const deserializeAws_restJson1UpdateSamplingRuleCommandError = async ( throw await deserializeAws_restJson1ThrottledExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3884,7 +3911,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -3910,6 +3937,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/private/aws-echo-service/src/protocols/Aws_restJson1.ts b/private/aws-echo-service/src/protocols/Aws_restJson1.ts index 4427d1562a5f4..83df795bf258d 100644 --- a/private/aws-echo-service/src/protocols/Aws_restJson1.ts +++ b/private/aws-echo-service/src/protocols/Aws_restJson1.ts @@ -98,18 +98,19 @@ const deserializeAws_restJson1EchoCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode: string = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PalindromeException": case "aws.test.generic#PalindromeException": throw await deserializeAws_restJson1PalindromeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -142,18 +143,19 @@ const deserializeAws_restJson1LengthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode: string = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "PalindromeException": case "aws.test.generic#PalindromeException": throw await deserializeAws_restJson1PalindromeExceptionResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -212,7 +214,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -238,6 +240,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/private/aws-protocoltests-ec2/src/protocols/Aws_ec2.ts b/private/aws-protocoltests-ec2/src/protocols/Aws_ec2.ts index 39a6c49f0fb59..dd4ac0e2b90a3 100644 --- a/private/aws-protocoltests-ec2/src/protocols/Aws_ec2.ts +++ b/private/aws-protocoltests-ec2/src/protocols/Aws_ec2.ts @@ -456,15 +456,16 @@ const deserializeAws_ec2EmptyInputAndEmptyOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -493,15 +494,16 @@ const deserializeAws_ec2EndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -530,15 +532,16 @@ const deserializeAws_ec2EndpointWithHostLabelOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -570,8 +573,7 @@ const deserializeAws_ec2GreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.ec2#ComplexError": @@ -581,10 +583,12 @@ const deserializeAws_ec2GreetingWithErrorsCommandError = async ( throw await deserializeAws_ec2InvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -613,15 +617,16 @@ const deserializeAws_ec2HostWithPathOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -653,15 +658,16 @@ const deserializeAws_ec2IgnoresWrappingXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -690,15 +696,16 @@ const deserializeAws_ec2NestedStructuresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -730,15 +737,16 @@ const deserializeAws_ec2NoInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -767,15 +775,16 @@ const deserializeAws_ec2QueryIdempotencyTokenAutoFillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -804,15 +813,16 @@ const deserializeAws_ec2QueryListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -841,15 +851,16 @@ const deserializeAws_ec2QueryTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -881,15 +892,16 @@ const deserializeAws_ec2RecursiveXmlShapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -918,15 +930,16 @@ const deserializeAws_ec2SimpleInputParamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -958,15 +971,16 @@ const deserializeAws_ec2SimpleScalarXmlPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -998,15 +1012,16 @@ const deserializeAws_ec2XmlBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1038,15 +1053,16 @@ const deserializeAws_ec2XmlEmptyBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1078,15 +1094,16 @@ const deserializeAws_ec2XmlEmptyListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1118,15 +1135,16 @@ const deserializeAws_ec2XmlEnumsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1158,15 +1176,16 @@ const deserializeAws_ec2XmlListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1198,15 +1217,16 @@ const deserializeAws_ec2XmlNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -1238,15 +1258,16 @@ const deserializeAws_ec2XmlTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadEc2ErrorCode(output, parsedOutput.body); + const errorCode = loadEc2ErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode, + name: parsedBody.Errors.Error.code || parsedBody.Errors.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Errors.Error); } @@ -2106,12 +2127,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadEc2ErrorCode = (output: __HttpResponse, data: any): string => { +const loadEc2ErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Errors.Error.Code !== undefined) { return data.Errors.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/private/aws-protocoltests-json-10/src/protocols/Aws_json1_0.ts b/private/aws-protocoltests-json-10/src/protocols/Aws_json1_0.ts index 529a1936883c3..040dcd35bd867 100644 --- a/private/aws-protocoltests-json-10/src/protocols/Aws_json1_0.ts +++ b/private/aws-protocoltests-json-10/src/protocols/Aws_json1_0.ts @@ -223,15 +223,16 @@ const deserializeAws_json1_0EmptyInputAndEmptyOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -260,15 +261,16 @@ const deserializeAws_json1_0EndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -297,15 +299,16 @@ const deserializeAws_json1_0EndpointWithHostLabelOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -337,8 +340,7 @@ const deserializeAws_json1_0GreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.json10#ComplexError": @@ -351,10 +353,12 @@ const deserializeAws_json1_0GreetingWithErrorsCommandError = async ( throw await deserializeAws_json1_0InvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -383,15 +387,16 @@ const deserializeAws_json1_0HostWithPathOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -423,15 +428,16 @@ const deserializeAws_json1_0JsonUnionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -460,15 +466,16 @@ const deserializeAws_json1_0NoInputAndNoOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -500,15 +507,16 @@ const deserializeAws_json1_0NoInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -540,15 +548,16 @@ const deserializeAws_json1_0SimpleScalarPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -869,7 +878,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -895,6 +904,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/private/aws-protocoltests-json/src/protocols/Aws_json1_1.ts b/private/aws-protocoltests-json/src/protocols/Aws_json1_1.ts index 20e244afb6c8e..9375e66be62c9 100644 --- a/private/aws-protocoltests-json/src/protocols/Aws_json1_1.ts +++ b/private/aws-protocoltests-json/src/protocols/Aws_json1_1.ts @@ -280,15 +280,16 @@ const deserializeAws_json1_1EmptyOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -317,15 +318,16 @@ const deserializeAws_json1_1EndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -354,15 +356,16 @@ const deserializeAws_json1_1EndpointWithHostLabelOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -394,8 +397,7 @@ const deserializeAws_json1_1GreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.json#ComplexError": @@ -408,10 +410,12 @@ const deserializeAws_json1_1GreetingWithErrorsCommandError = async ( throw await deserializeAws_json1_1InvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -440,15 +444,16 @@ const deserializeAws_json1_1HostWithPathOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -480,15 +485,16 @@ const deserializeAws_json1_1JsonEnumsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -520,15 +526,16 @@ const deserializeAws_json1_1JsonUnionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -560,8 +567,7 @@ const deserializeAws_json1_1KitchenSinkOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ErrorWithMembers": case "aws.protocoltests.json#ErrorWithMembers": @@ -571,10 +577,12 @@ const deserializeAws_json1_1KitchenSinkOperationCommandError = async ( throw await deserializeAws_json1_1ErrorWithoutMembersResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -606,15 +614,16 @@ const deserializeAws_json1_1NullOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -646,15 +655,16 @@ const deserializeAws_json1_1OperationWithOptionalInputOutputCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -686,15 +696,16 @@ const deserializeAws_json1_1PutAndGetInlineDocumentsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -726,15 +737,16 @@ const deserializeAws_json1_1SimpleScalarPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -1737,7 +1749,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -1763,6 +1775,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/private/aws-protocoltests-query/src/protocols/Aws_query.ts b/private/aws-protocoltests-query/src/protocols/Aws_query.ts index 0aa0918fd88f1..be3c7368edbd2 100644 --- a/private/aws-protocoltests-query/src/protocols/Aws_query.ts +++ b/private/aws-protocoltests-query/src/protocols/Aws_query.ts @@ -595,15 +595,16 @@ const deserializeAws_queryEmptyInputAndEmptyOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -632,15 +633,16 @@ const deserializeAws_queryEndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -669,15 +671,16 @@ const deserializeAws_queryEndpointWithHostLabelOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -709,15 +712,16 @@ const deserializeAws_queryFlattenedXmlMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -749,15 +753,16 @@ const deserializeAws_queryFlattenedXmlMapWithXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -792,15 +797,16 @@ const deserializeAws_queryFlattenedXmlMapWithXmlNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -832,8 +838,7 @@ const deserializeAws_queryGreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.query#ComplexError": @@ -846,10 +851,12 @@ const deserializeAws_queryGreetingWithErrorsCommandError = async ( throw await deserializeAws_queryInvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -878,15 +885,16 @@ const deserializeAws_queryHostWithPathOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -918,15 +926,16 @@ const deserializeAws_queryIgnoresWrappingXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -955,15 +964,16 @@ const deserializeAws_queryNestedStructuresCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -992,15 +1002,16 @@ const deserializeAws_queryNoInputAndNoOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1032,15 +1043,16 @@ const deserializeAws_queryNoInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1069,15 +1081,16 @@ const deserializeAws_queryQueryIdempotencyTokenAutoFillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1106,15 +1119,16 @@ const deserializeAws_queryQueryListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1143,15 +1157,16 @@ const deserializeAws_queryQueryMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1180,15 +1195,16 @@ const deserializeAws_queryQueryTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1220,15 +1236,16 @@ const deserializeAws_queryRecursiveXmlShapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1257,15 +1274,16 @@ const deserializeAws_querySimpleInputParamsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1297,15 +1315,16 @@ const deserializeAws_querySimpleScalarXmlPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1337,15 +1356,16 @@ const deserializeAws_queryXmlBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1377,15 +1397,16 @@ const deserializeAws_queryXmlEmptyBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1417,15 +1438,16 @@ const deserializeAws_queryXmlEmptyListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1457,15 +1479,16 @@ const deserializeAws_queryXmlEmptyMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1497,15 +1520,16 @@ const deserializeAws_queryXmlEnumsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1537,15 +1561,16 @@ const deserializeAws_queryXmlListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1577,15 +1602,16 @@ const deserializeAws_queryXmlMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1617,15 +1643,16 @@ const deserializeAws_queryXmlMapsXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1657,15 +1684,16 @@ const deserializeAws_queryXmlNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -1697,15 +1725,16 @@ const deserializeAws_queryXmlTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadQueryErrorCode(output, parsedOutput.body); + const errorCode = loadQueryErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2882,12 +2911,11 @@ const buildFormUrlencodedString = (formEntries: Record): string .map(([key, value]) => __extendedEncodeURIComponent(key) + "=" + __extendedEncodeURIComponent(value)) .join("&"); -const loadQueryErrorCode = (output: __HttpResponse, data: any): string => { +const loadQueryErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; }; diff --git a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts index 4435a3bb3c3e3..e2e3ad931513e 100644 --- a/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts +++ b/private/aws-protocoltests-restjson/src/protocols/Aws_restJson1.ts @@ -2918,15 +2918,16 @@ const deserializeAws_restJson1AllQueryStringTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2955,15 +2956,16 @@ const deserializeAws_restJson1ConstantAndVariableQueryStringCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -2992,15 +2994,16 @@ const deserializeAws_restJson1ConstantQueryStringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3037,15 +3040,16 @@ const deserializeAws_restJson1DocumentTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3077,15 +3081,16 @@ const deserializeAws_restJson1DocumentTypeAsPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3114,15 +3119,16 @@ const deserializeAws_restJson1EmptyInputAndEmptyOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3151,15 +3157,16 @@ const deserializeAws_restJson1EndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3188,15 +3195,16 @@ const deserializeAws_restJson1EndpointWithHostLabelOperationCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3229,8 +3237,7 @@ const deserializeAws_restJson1GreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.restjson#ComplexError": @@ -3243,10 +3250,12 @@ const deserializeAws_restJson1GreetingWithErrorsCommandError = async ( throw await deserializeAws_restJson1InvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3275,15 +3284,16 @@ const deserializeAws_restJson1HostWithPathOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3316,15 +3326,16 @@ const deserializeAws_restJson1HttpChecksumRequiredCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3355,15 +3366,16 @@ const deserializeAws_restJson1HttpEnumPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3398,15 +3410,16 @@ const deserializeAws_restJson1HttpPayloadTraitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3441,15 +3454,16 @@ const deserializeAws_restJson1HttpPayloadTraitsWithMediaTypeCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3480,15 +3494,16 @@ const deserializeAws_restJson1HttpPayloadWithStructureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3530,15 +3545,16 @@ const deserializeAws_restJson1HttpPrefixHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3576,15 +3592,16 @@ const deserializeAws_restJson1HttpPrefixHeadersInResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3613,15 +3630,16 @@ const deserializeAws_restJson1HttpRequestWithFloatLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3650,15 +3668,16 @@ const deserializeAws_restJson1HttpRequestWithGreedyLabelInPathCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3687,15 +3706,16 @@ const deserializeAws_restJson1HttpRequestWithLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3724,15 +3744,16 @@ const deserializeAws_restJson1HttpRequestWithLabelsAndTimestampFormatCommandErro body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3761,15 +3782,16 @@ const deserializeAws_restJson1HttpRequestWithRegexLiteralCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3802,15 +3824,16 @@ const deserializeAws_restJson1HttpResponseCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3841,15 +3864,16 @@ const deserializeAws_restJson1HttpStringPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3882,15 +3906,16 @@ const deserializeAws_restJson1IgnoreQueryParamsInResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -3989,15 +4014,16 @@ const deserializeAws_restJson1InputAndOutputWithHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4030,15 +4056,16 @@ const deserializeAws_restJson1JsonBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4091,15 +4118,16 @@ const deserializeAws_restJson1JsonEnumsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4164,15 +4192,16 @@ const deserializeAws_restJson1JsonListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4241,15 +4270,16 @@ const deserializeAws_restJson1JsonMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4294,15 +4324,16 @@ const deserializeAws_restJson1JsonTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4335,15 +4366,16 @@ const deserializeAws_restJson1JsonUnionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4376,15 +4408,16 @@ const deserializeAws_restJson1MalformedAcceptWithBodyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4413,15 +4446,16 @@ const deserializeAws_restJson1MalformedAcceptWithGenericStringCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4452,15 +4486,16 @@ const deserializeAws_restJson1MalformedAcceptWithPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4489,15 +4524,16 @@ const deserializeAws_restJson1MalformedBlobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4526,15 +4562,16 @@ const deserializeAws_restJson1MalformedBooleanCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4563,15 +4600,16 @@ const deserializeAws_restJson1MalformedByteCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4600,15 +4638,16 @@ const deserializeAws_restJson1MalformedContentTypeWithBodyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4637,15 +4676,16 @@ const deserializeAws_restJson1MalformedContentTypeWithGenericStringCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4674,15 +4714,16 @@ const deserializeAws_restJson1MalformedContentTypeWithoutBodyCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4711,15 +4752,16 @@ const deserializeAws_restJson1MalformedContentTypeWithPayloadCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4748,15 +4790,16 @@ const deserializeAws_restJson1MalformedDoubleCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4785,15 +4828,16 @@ const deserializeAws_restJson1MalformedFloatCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4822,15 +4866,16 @@ const deserializeAws_restJson1MalformedIntegerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4859,15 +4904,16 @@ const deserializeAws_restJson1MalformedListCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4896,15 +4942,16 @@ const deserializeAws_restJson1MalformedLongCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4933,15 +4980,16 @@ const deserializeAws_restJson1MalformedMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -4970,15 +5018,16 @@ const deserializeAws_restJson1MalformedRequestBodyCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5007,15 +5056,16 @@ const deserializeAws_restJson1MalformedSetCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5044,15 +5094,16 @@ const deserializeAws_restJson1MalformedShortCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5081,15 +5132,16 @@ const deserializeAws_restJson1MalformedStringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5118,15 +5170,16 @@ const deserializeAws_restJson1MalformedTimestampBodyDateTimeCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5155,15 +5208,16 @@ const deserializeAws_restJson1MalformedTimestampBodyDefaultCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5192,15 +5246,16 @@ const deserializeAws_restJson1MalformedTimestampBodyHttpDateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5229,15 +5284,16 @@ const deserializeAws_restJson1MalformedTimestampHeaderDateTimeCommandError = asy body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5266,15 +5322,16 @@ const deserializeAws_restJson1MalformedTimestampHeaderDefaultCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5303,15 +5360,16 @@ const deserializeAws_restJson1MalformedTimestampHeaderEpochCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5340,15 +5398,16 @@ const deserializeAws_restJson1MalformedTimestampPathDefaultCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5377,15 +5436,16 @@ const deserializeAws_restJson1MalformedTimestampPathEpochCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5414,15 +5474,16 @@ const deserializeAws_restJson1MalformedTimestampPathHttpDateCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5451,15 +5512,16 @@ const deserializeAws_restJson1MalformedTimestampQueryDefaultCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5488,15 +5550,16 @@ const deserializeAws_restJson1MalformedTimestampQueryEpochCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5525,15 +5588,16 @@ const deserializeAws_restJson1MalformedTimestampQueryHttpDateCommandError = asyn body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5562,15 +5626,16 @@ const deserializeAws_restJson1MalformedUnionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5603,15 +5668,16 @@ const deserializeAws_restJson1MediaTypeHeaderCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5640,15 +5706,16 @@ const deserializeAws_restJson1NoInputAndNoOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5677,15 +5744,16 @@ const deserializeAws_restJson1NoInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5726,15 +5794,16 @@ const deserializeAws_restJson1NullAndEmptyHeadersClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5775,15 +5844,16 @@ const deserializeAws_restJson1NullAndEmptyHeadersServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5812,15 +5882,16 @@ const deserializeAws_restJson1OmitsNullSerializesEmptyStringCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5853,15 +5924,16 @@ const deserializeAws_restJson1PostPlayerActionCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5890,15 +5962,16 @@ const deserializeAws_restJson1QueryIdempotencyTokenAutoFillCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5927,15 +6000,16 @@ const deserializeAws_restJson1QueryParamsAsStringListMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -5964,15 +6038,16 @@ const deserializeAws_restJson1QueryPrecedenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6005,15 +6080,16 @@ const deserializeAws_restJson1RecursiveShapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6082,15 +6158,16 @@ const deserializeAws_restJson1SimpleScalarPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6125,15 +6202,16 @@ const deserializeAws_restJson1StreamingTraitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6162,15 +6240,16 @@ const deserializeAws_restJson1StreamingTraitsRequireLengthCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6205,15 +6284,16 @@ const deserializeAws_restJson1StreamingTraitsWithMediaTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6250,15 +6330,16 @@ const deserializeAws_restJson1TestBodyStructureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6291,15 +6372,16 @@ const deserializeAws_restJson1TestNoPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6334,15 +6416,16 @@ const deserializeAws_restJson1TestPayloadBlobCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6377,15 +6460,16 @@ const deserializeAws_restJson1TestPayloadStructureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6442,15 +6526,16 @@ const deserializeAws_restJson1TimestampFormatHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -6479,15 +6564,16 @@ const deserializeAws_restJson1UnitInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestJsonErrorCode(output, parsedOutput.body); + const errorCode = loadRestJsonErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.code || parsedBody.Code || errorCode, + name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody); } @@ -7387,7 +7473,7 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => /** * Load an error code for the aws.rest-json-1.1 protocol. */ -const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string | undefined => { const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); const sanitizeErrorCode = (rawValue: string): string => { @@ -7413,6 +7499,4 @@ const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => { if (data["__type"] !== undefined) { return sanitizeErrorCode(data["__type"]); } - - return ""; }; diff --git a/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts b/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts index fc699840f6e27..1da479b220cea 100644 --- a/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts +++ b/private/aws-protocoltests-restxml/src/protocols/Aws_restXml.ts @@ -2249,15 +2249,16 @@ const deserializeAws_restXmlAllQueryStringTypesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2290,15 +2291,16 @@ const deserializeAws_restXmlBodyWithXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2327,15 +2329,16 @@ const deserializeAws_restXmlConstantAndVariableQueryStringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2364,15 +2367,16 @@ const deserializeAws_restXmlConstantQueryStringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2401,15 +2405,16 @@ const deserializeAws_restXmlEmptyInputAndEmptyOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2438,15 +2443,16 @@ const deserializeAws_restXmlEndpointOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2475,15 +2481,16 @@ const deserializeAws_restXmlEndpointWithHostLabelHeaderOperationCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2512,15 +2519,16 @@ const deserializeAws_restXmlEndpointWithHostLabelOperationCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2555,15 +2563,16 @@ const deserializeAws_restXmlFlattenedXmlMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2601,15 +2610,16 @@ const deserializeAws_restXmlFlattenedXmlMapWithXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2647,15 +2657,16 @@ const deserializeAws_restXmlFlattenedXmlMapWithXmlNamespaceCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2688,8 +2699,7 @@ const deserializeAws_restXmlGreetingWithErrorsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { case "ComplexError": case "aws.protocoltests.restxml#ComplexError": @@ -2699,10 +2709,12 @@ const deserializeAws_restXmlGreetingWithErrorsCommandError = async ( throw await deserializeAws_restXmlInvalidGreetingResponse(parsedOutput, context); default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2737,15 +2749,16 @@ const deserializeAws_restXmlHttpPayloadTraitsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2780,15 +2793,16 @@ const deserializeAws_restXmlHttpPayloadTraitsWithMediaTypeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2819,15 +2833,16 @@ const deserializeAws_restXmlHttpPayloadWithMemberXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2858,15 +2873,16 @@ const deserializeAws_restXmlHttpPayloadWithStructureCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2897,15 +2913,16 @@ const deserializeAws_restXmlHttpPayloadWithXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2936,15 +2953,16 @@ const deserializeAws_restXmlHttpPayloadWithXmlNamespaceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -2975,15 +2993,16 @@ const deserializeAws_restXmlHttpPayloadWithXmlNamespaceAndPrefixCommandError = a body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3025,15 +3044,16 @@ const deserializeAws_restXmlHttpPrefixHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3062,15 +3082,16 @@ const deserializeAws_restXmlHttpRequestWithFloatLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3099,15 +3120,16 @@ const deserializeAws_restXmlHttpRequestWithGreedyLabelInPathCommandError = async body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3136,15 +3158,16 @@ const deserializeAws_restXmlHttpRequestWithLabelsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3173,15 +3196,16 @@ const deserializeAws_restXmlHttpRequestWithLabelsAndTimestampFormatCommandError body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3214,15 +3238,16 @@ const deserializeAws_restXmlHttpResponseCodeCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3255,15 +3280,16 @@ const deserializeAws_restXmlIgnoreQueryParamsInResponseCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3362,15 +3388,16 @@ const deserializeAws_restXmlInputAndOutputWithHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3411,15 +3438,16 @@ const deserializeAws_restXmlNestedXmlMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3448,15 +3476,16 @@ const deserializeAws_restXmlNoInputAndNoOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3485,15 +3514,16 @@ const deserializeAws_restXmlNoInputAndOutputCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3534,15 +3564,16 @@ const deserializeAws_restXmlNullAndEmptyHeadersClientCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3583,15 +3614,16 @@ const deserializeAws_restXmlNullAndEmptyHeadersServerCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3620,15 +3652,16 @@ const deserializeAws_restXmlOmitsNullSerializesEmptyStringCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3657,15 +3690,16 @@ const deserializeAws_restXmlQueryIdempotencyTokenAutoFillCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3694,15 +3728,16 @@ const deserializeAws_restXmlQueryParamsAsStringListMapCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3731,15 +3766,16 @@ const deserializeAws_restXmlQueryPrecedenceCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3772,15 +3808,16 @@ const deserializeAws_restXmlRecursiveShapesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3849,15 +3886,16 @@ const deserializeAws_restXmlSimpleScalarPropertiesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3914,15 +3952,16 @@ const deserializeAws_restXmlTimestampFormatHeadersCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3959,15 +3998,16 @@ const deserializeAws_restXmlXmlAttributesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -3998,15 +4038,16 @@ const deserializeAws_restXmlXmlAttributesOnPayloadCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4039,15 +4080,16 @@ const deserializeAws_restXmlXmlBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4080,15 +4122,16 @@ const deserializeAws_restXmlXmlEmptyBlobsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4237,15 +4280,16 @@ const deserializeAws_restXmlXmlEmptyListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4283,15 +4327,16 @@ const deserializeAws_restXmlXmlEmptyMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4324,15 +4369,16 @@ const deserializeAws_restXmlXmlEmptyStringsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4400,15 +4446,16 @@ const deserializeAws_restXmlXmlEnumsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4557,15 +4604,16 @@ const deserializeAws_restXmlXmlListsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4603,15 +4651,16 @@ const deserializeAws_restXmlXmlMapsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4649,15 +4698,16 @@ const deserializeAws_restXmlXmlMapsXmlNameCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4690,15 +4740,16 @@ const deserializeAws_restXmlXmlNamespacesCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4743,15 +4794,16 @@ const deserializeAws_restXmlXmlTimestampsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -4786,15 +4838,16 @@ const deserializeAws_restXmlXmlUnionsCommandError = async ( body: await parseBody(output.body, context), }; let response: __BaseException; - let errorCode = "UnknownError"; - errorCode = loadRestXmlErrorCode(output, parsedOutput.body); + const errorCode = loadRestXmlErrorCode(output, parsedOutput.body); switch (errorCode) { default: const parsedBody = parsedOutput.body; + const $metadata = deserializeMetadata(output); + const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined; response = new __BaseException({ - name: parsedBody.Error.code || parsedBody.Error.Code || errorCode, + name: parsedBody.Error.code || parsedBody.Error.Code || errorCode || statusCode || "UnknowError", $fault: "client", - $metadata: deserializeMetadata(output), + $metadata, }); throw __decorateServiceException(response, parsedBody.Error); } @@ -5840,12 +5893,11 @@ const parseBody = (streamBody: any, context: __SerdeContext): any => return {}; }); -const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string => { +const loadRestXmlErrorCode = (output: __HttpResponse, data: any): string | undefined => { if (data.Error.Code !== undefined) { return data.Error.Code; } if (output.statusCode == 404) { return "NotFound"; } - return ""; };